~nochka85/cairo-dock-plug-ins/quick_rss_reader

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash  

# This is a part of the external applet quick_rss_reader.py for Cairo-Dock
# (based on the RSS Display Script by Bill Woodford (admin@sdesign.us))
#
# Copyright : (C) 2009 by Yann Dulieu (Nochka85)
# E-mail : nochka85@cairo-dock.org
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# http://www.gnu.org/licenses/licenses.html#GPL
#
#
# Rev : 0.0.4
# Date : 09/09/20


URL=$1
LINES=$2
TITLE_NUM=$3

#############################################################################################################
# START ### DO NOT CHANGE THIS SECTION
#############################################################################################################

if [[ "$URL" == "" ]]; then
    echo "$APP_NAME applet -> Script Name : $SCRIPT_NAME -> No URL specified !" >&2
else
	### Set defaults values if none specified
	if [[ $LINES == "" ]]; then
		LINES=5
	fi

	if [[ $TITLE_NUM == "" ]]; then
		TITLE_NUM=1
	fi

	curl -s --connect-timeout 300 $URL |\
	sed -e 's/<\/title>/\n/g' |\
	grep -o '<title>.*' |\
	sed -e 's/<title>//' |\
	sed -e 's/<\!\[CDATA\[//' |\
	sed -e 's/\]\]>//' |\
	head -n $(($LINES + $TITLE_NUM)) |\
	tail -n $(($LINES))
fi

exit