Aktualny program telewizyjny w conky i pogoda na nast

Archiwalne, stare wpisy FAQ i HowTo Użytkowników
filip.cy
Posty: 47
Rejestracja: 03 czerwca 2008, 23:28

Aktualny program telewizyjny w conky i pogoda na następny dzień

Post autor: filip.cy »

Witam.

Nigdzie nie widziałem takiego czegoś więc sam napisałem.
Proszę o wyrozumiałość to moje pierwsze skrypty, tworzą one trochę plików, ale mnie to nie przeszkadza, zawsze można je usunąć lub jakoś składniej napisać. Wszelkie uwagi mile widziane.


Program telewizyjny

Tworzymy pusty plik:

Kod: Zaznacz cały

touch tv
Nadajemy odpowiednie prawa do jego wykonywania:

Kod: Zaznacz cały

chmod +x tv
Edytujemy plik w swoim ulubionym edytorze np.: pico (nano, kate itp.).

Kod: Zaznacz cały

nano tv

Plik tv uzupełniamy poniższą treścią:

Kod: Zaznacz cały

#!/bin/sh

curl -s [url]http://serwisy.gazeta.pl/tv/1617365,47460,1686289.html?nrpg=1[/url] |iconv -f iso-8859-2 -t utf-8 > program
curl -s [url]http://serwisy.gazeta.pl/tv/1617365,47460,1686289.html?nrpg=4[/url] |iconv -f iso-8859-2 -t utf-8 >> program
curl -s [url]http://serwisy.gazeta.pl/tv/1617365,47460,1686289.html?nrpg=6[/url] |iconv -f iso-8859-2 -t utf-8 >> program

cat program |grep p12m > test1
cat test1 |sed -e 's/<[^>]*>//g' > test2
cat -n test2 > test3
cat test3 |sed -n -e '1,8p' > programik
cat test3 |sed -n -e '13,14p' >>programik
cat test3 |sed -n -e '19p' >> programik
cat test3 |sed -n -e '20p' >> programik
cat test3 |sed -n -e '41p' >>programik
cat test3 |sed -n -e '42p' >>programik
cat programik |cut -b 16- > tele
cat -n tele > tele1
rm test1
rm test2
rm test3
rm programik
rm tele
Uzupełniamy poniższy wpis w naszym ~/.conkycr:

Kod: Zaznacz cały

${offset 240}${color }TVP1     ${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 1/p' |cut -b 3-}${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 2/p' |cut -b 7-}
${offset 240}${color }TVP2     ${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 3/p' |cut -b 3-}${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 4/p' |cut -b 7-}
${offset 240}${color }Polsat   ${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 5/p' |cut -b 3-}${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 6/p' |cut -b 7-}
${offset 240}${color }TVN       ${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 7/p' |cut -b 3-}${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 8/p' |cut -b 7-}
${offset 240}${color }TVN 7    ${exec cat /home/filip/tele1 |cut -b 5- |sed -n -e '/^ 9/p' |cut -b 3-}${exec cat /home/filip/tele1 |cut -b 4- |sed -n -e '/^ 10/p' |cut -b 8-}
${offset 240}${color }Eurosp   ${exec cat /home/filip/tele1 |cut -b 4- |sed -n -e '/^ 11/p' |cut -b 4-}${exec cat /home/filip/tele1 |cut -b 4- |sed -n -e '/^ 12/p' |cut -b 8-}
${offset 240}${color }P.Sport  ${exec cat /home/filip/tele1 |cut -b 4- |sed -n -e '/^ 13/p' |cut -b 4-}${exec cat /home/filip/tele1 |cut -b 4- |sed -n -e '/^ 14/p' 
Oczywiście w conky zmieniamy ścieżkę do katalogu gdzie umieścimy nasz skrypt tv.
Skrypt ten tworzy plik tele1 w tym samym katalogu, u mnie jak widać w /home/filip


Pogoda na następny dzień

Tworzymy pusty plik:

Kod: Zaznacz cały

touch pogoda1
Prawa wykonywania dla pliku:

Kod: Zaznacz cały

chmod +x pogoda1
Edytujemy plik w swoim ulubionym edytorze np.: pico (nano, kate itp.).

Kod: Zaznacz cały

nano pogoda1
Plik pogoda1 uzupełniamy poniższą treścią:

Kod: Zaznacz cały

#!/bin/sh

/bin/date > /home/filip/pogoda/data

cut /home/filip/pogoda/data -b -2 > /home/filip/pogoda/data1

exec 6</home/filip/pogoda/data1

read -u 6 dane

if test $dane == "po"
then curl -s [url]http://pogoda.wp.pl/miasto,poznan,mid,1201201,mi.html[/url] |iconv -f iso-8859-2 -t utf8 |nl -ba > /home/filip/pogoda/sciagniete
cat /home/filip/pogoda/sciagniete |sed -n -e '275,279p' |sed -e 's/<[^>]*>//g' |cut -b 8- |nl -ba > pogoda
elif test $dane == "wt"
then curl -s [url]http://pogoda.wp.pl/miasto,poznan,mid,1201201,mi.html[/url] |iconv -f iso-8859-2 -t utf8 |nl -ba > /home/filip/pogoda/sciagniete
cat /home/filip/pogoda/sciagniete |sed -n -e '275,279p' |sed -e 's/<[^>]*>//g' |cut -b 8- |nl -ba > /home/filip/pogoda/pogoda
elif test $dane == "ś"
then curl -s [url]http://pogoda.wp.pl/miasto,poznan,mid,1201201,mi.html[/url] |iconv -f iso-8859-2 -t utf8 |nl -ba > /home/filip/pogoda/sciagniete
cat /home/filip/pogoda/sciagniete |sed -n -e '275,279p' |sed -e 's/<[^>]*>//g' |cut -b 8- |nl -ba > /home/filip/pogoda/pogoda
elif test $dane == "cz"
then curl -s [url]http://pogoda.wp.pl/miasto,poznan,mid,1201201,mi.html[/url] |iconv -f iso-8859-2 -t utf8 |nl -ba > /home/filip/pogoda/sciagniete
cat /home/filip/pogoda/sciagniete |sed -n -e '275,279p' |sed -e 's/<[^>]*>//g' |cut -b 8- |nl -ba > /home/filip/pogoda/pogoda
elif test $dane == "pi"
then curl -s [url]http://pogoda.wp.pl/miasto,poznan,mid,1201201,mi.html[/url] |iconv -f iso-8859-2 -t utf8 |nl -ba > /home/filip/pogoda/sciagniete
cat /home/filip/pogoda/sciagniete |sed -n -e '275,279p' |sed -e 's/<[^>]*>//g' |cut -b 8- |nl -ba > /home/filip/pogoda/pogoda
elif test $dane == "so"
then curl -s [url]http://pogoda.wp.pl/miasto,poznan,mid,1201201,mi.html[/url] |iconv -f iso-8859-2 -t utf8 |nl -ba > /home/filip/pogoda/sciagniete
cat /home/filip/pogoda/sciagniete |sed -n -e '275,279p' |sed -e 's/<[^>]*>//g' |cut -b 8- |nl -ba > /home/filip/pogoda/pogoda
elif test $dane == "ni"
then curl -s [url]http://pogoda.wp.pl/miasto,poznan,mid,1201201,mi.html[/url] |iconv -f iso-8859-2 -t utf8 |nl -ba > /home/filip/pogoda/sciagniete
cat /home/filip/pogoda/sciagniete |sed -n -e '275,279p' |sed -e 's/<[^>]*>//g' |cut -b 8- |nl -ba > /home/filip/pogoda/pogoda
fi

   exec 6<&-
Zmieniamy ścieżki do pliku pogoda1 na taką jaką mamy w systemie.

Uzupełniamy poniższy wpis w naszym ~/.conkycr:

Kod: Zaznacz cały

${offset 240}${color #FFFF00} Pogoda na: ${color }${exec cat /home/filip/pogoda/pogoda |cut -b 5- |sed -n -e '/^ 1/p' |cut -b 4-}
${offset 240}${color #FFFF00} Temperatura max: ${color #ddaa00}${exec cat /home/filip/pogoda/pogoda |cut -b 5- |sed -n -e '/^ 3/p' |cut -b 19-23}
${offset 240}${color #FFFF00} Temperatura min: ${color slate grey}${exec cat /home/filip/pogoda/pogoda |cut -b 5- |sed -n -e '/^ 3/p' |cut -b 39-}
${offset 240}${color #FFFF00} Wiatr: ${color }${exec cat /home/filip/pogoda/pogoda |cut -b 5- |sed -n -e '/^ 4/p' |cut -b 11-}
${offset 240}${color #FFFF00} ${exec cat /home/filip/pogoda/pogoda |cut -b 5- |sed -n -e '/^ 2/p' |cut -b 4-}
J.w. zmieniamy ścieżki na odpowiednie do naszej sytuacji w systemie dla pliku pogoda, który tworzony jest przez skrypt pogoda1

Skrypt pogoda jeden, testowany był dla dni wtorek i środa.
Zobaczymy jak będzie działał dla pozostałych ale mam nadzieję że dobrze.

Miłego korzystania.
Zablokowany