From 78f7be4e4b6501b15b5fefc9f7824bbadf0daf2a Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Fri, 13 Jun 2014 21:12:21 +0800 Subject: Added various dotfiles. * Xresources * profile, xprofile, xinitrc * bash (aliases, logout, profile, rc, completion) * gitconfig * gtkrc and gtk-bookmarks * i3 configs (with py3status configs) * i3status.conf * lftp/rc * tmux.conf * xbindkeysrc * mpdconf * ncmpcpp (config and keys) * sbclrc * vifm (vifmrc, colors) * urxvt (perl extensions) * conkyrc (and conky/cronograph configs) --- .conky/cronograph/accuweather/accuweather.sh | 172 +++ .conky/cronograph/accuweather/curr_cond | 5 + .conky/cronograph/accuweather/curr_cond_raw | 1646 ++++++++++++++++++++++++++ .conky/cronograph/accuweather/last_days | 25 + .conky/cronograph/accuweather/last_days_raw | 82 ++ .conky/cronograph/accuweather/tod_ton | 25 + .conky/cronograph/accuweather/tod_ton_raw | 81 ++ .conky/cronograph/conky_start.sh | 10 + .conky/cronograph/conkyrc | 89 ++ .conky/cronograph/images/Blank.png | Bin 0 -> 11356 bytes .conky/cronograph/images/Blue.png | Bin 0 -> 11605 bytes .conky/cronograph/images/Dark_Green.png | Bin 0 -> 12198 bytes .conky/cronograph/images/Dark_Purple.png | Bin 0 -> 11429 bytes .conky/cronograph/images/Green.png | Bin 0 -> 11963 bytes .conky/cronograph/images/Orange.png | Bin 0 -> 11767 bytes .conky/cronograph/images/Pink.png | Bin 0 -> 11514 bytes .conky/cronograph/images/Purple.png | Bin 0 -> 11335 bytes .conky/cronograph/images/Red.png | Bin 0 -> 11470 bytes .conky/cronograph/images/Yellow.png | Bin 0 -> 11889 bytes .conky/cronograph/scripts/blinkingLED | 3 + .conky/cronograph/scripts/clock_rings.lua | 358 ++++++ .conky/cronograph/scripts/multi_rings.lua | 375 ++++++ 22 files changed, 2871 insertions(+) create mode 100755 .conky/cronograph/accuweather/accuweather.sh create mode 100644 .conky/cronograph/accuweather/curr_cond create mode 100644 .conky/cronograph/accuweather/curr_cond_raw create mode 100644 .conky/cronograph/accuweather/last_days create mode 100644 .conky/cronograph/accuweather/last_days_raw create mode 100644 .conky/cronograph/accuweather/tod_ton create mode 100644 .conky/cronograph/accuweather/tod_ton_raw create mode 100755 .conky/cronograph/conky_start.sh create mode 100644 .conky/cronograph/conkyrc create mode 100644 .conky/cronograph/images/Blank.png create mode 100644 .conky/cronograph/images/Blue.png create mode 100644 .conky/cronograph/images/Dark_Green.png create mode 100644 .conky/cronograph/images/Dark_Purple.png create mode 100644 .conky/cronograph/images/Green.png create mode 100644 .conky/cronograph/images/Orange.png create mode 100644 .conky/cronograph/images/Pink.png create mode 100644 .conky/cronograph/images/Purple.png create mode 100644 .conky/cronograph/images/Red.png create mode 100644 .conky/cronograph/images/Yellow.png create mode 100755 .conky/cronograph/scripts/blinkingLED create mode 100755 .conky/cronograph/scripts/clock_rings.lua create mode 100755 .conky/cronograph/scripts/multi_rings.lua (limited to '.conky') diff --git a/.conky/cronograph/accuweather/accuweather.sh b/.conky/cronograph/accuweather/accuweather.sh new file mode 100755 index 0000000..fe6a407 --- /dev/null +++ b/.conky/cronograph/accuweather/accuweather.sh @@ -0,0 +1,172 @@ +#!/bin/sh + +## get the directory of this script +SCRIPT_PATH=`readlink -f $0` +SCRIPT_DIR=`dirname ${SCRIPT_PATH}` + +## address (Accuweather url) +address="http://www.accuweather.com/en/cn/shanghai/106577/weather-forecast/106577" # Shanghai + + +## function: test_image() +test_image() { + case $1 in + 1) + echo a + ;; + 2|3) + echo b + ;; + 4|5) + echo c + ;; + 6) + echo d + ;; + 7) + echo e + ;; + 8) + echo f + ;; + 11) + echo 0 + ;; + 12) + echo h + ;; + 13|14) + echo g + ;; + 15) + echo m + ;; + 16|17) + echo k + ;; + 18) + echo i + ;; + 19) + echo q + ;; + 20|21|23) + echo o + ;; + 22) + echo r + ;; + 24|31) + echo E + ;; + 25) + echo v + ;; + 26) + echo x + ;; + 29) + echo y + ;; + 30) + echo 5 + ;; + 32) + echo 6 + ;; + 33) + echo A + ;; + 34|35) + echo B + ;; + 36|37) + echo C + ;; + 38) + echo D + ;; + 39|40) + echo G + ;; + 41|42) + echo K + ;; + 43|44) + echo O + ;; + *) + echo - + ;; + esac +} + + +#kill -STOP $(pidof conky) +#killall wget + +## urls and wget weather data +loc_id=$(echo ${address} | sed 's/\/weather-forecast.*$//' | sed 's/^.*\///') +last_number=$(echo ${address} | sed 's/^.*\///') + +curr_addr="$(echo ${address} | sed 's/weather-forecast.*$//')current-weather/${last_number}" +wget -O ${SCRIPT_DIR}/curr_cond_raw "${curr_addr}" + +addr1="$(echo ${address} | sed 's/weather-forecast.*$//')daily-weather-forecast/${last_number}" +wget -O ${SCRIPT_DIR}/tod_ton_raw "${addr1}" + +addr2="${addr1}?day=6" +wget -O ${SCRIPT_DIR}/last_days_raw "${addr2}" + +## current conditions +if [ -s ${SCRIPT_DIR}/curr_cond_raw ]; then + sed -i '/detail-now/,/#details/!d' ${SCRIPT_DIR}/curr_cond_raw + egrep -i '"cond"|icon i-|detail-tab-panel' ${SCRIPT_DIR}/curr_cond_raw > ${SCRIPT_DIR}/curr_cond + sed -i -e 's/^.*detail-tab-panel //g' -e 's/^.*icon i-//g' -e 's/"><\/div>.*$//g' ${SCRIPT_DIR}/curr_cond + sed -i -e 's/^.*"cond">//g' -e 's/°/\n/g' -e 's/<\/span>.*"temp">/\n/g' -e 's/<.*>//g' ${SCRIPT_DIR}/curr_cond + sed -i -e 's/">//g' -e 's/-->//g' -e 's/\r$//g' -e 's/ i-alarm.*$//g' -e 's/-[a-z].*$//g' ${SCRIPT_DIR}/curr_cond + image=$(sed -n 2p ${SCRIPT_DIR}/curr_cond) + sed -i 2s/${image}/$(test_image ${image})/ ${SCRIPT_DIR}/curr_cond +fi + +## First 5 days +if [ -s ${SCRIPT_DIR}/tod_ton_raw ]; then + sed -i '/feed-tabs/,/\.feed-tabs/!d' ${SCRIPT_DIR}/tod_ton_raw + egrep -i 'Early AM|Today|Tonight|Overnight|icon i-|cond|temp|Mon|Tue|Wed|Thu|Fri|Sat|Sun' ${SCRIPT_DIR}/tod_ton_raw > ${SCRIPT_DIR}/tod_ton + sed -i -e 's/^.*#">//g' -e 's/^.*icon i-//g' -e 's/^.*cond">//g' -e 's/^.*temp">//g' ${SCRIPT_DIR}/tod_ton + sed -i -e 's/Lo<\/span> /\n/g' -e 's/<\/a>.*$//g' -e 's/ "><.*$//g' -e 's/&#.*$//g' -e 's/teo//g' ${SCRIPT_DIR}/tod_ton + sed -i -e 's/.*$//g' -e 's/<\/span>//g' -e 's/\r$//g' -e 's/ i-alarm.*$//g' ${SCRIPT_DIR}/tod_ton + sed -i -e 's/Early AM/EARLY AM/' -e 's/Today/TODAY/' -e 's/Tonight/TONIGHT/' -e 's/Overnight/OVERNIGHT/' -e 's/Mon/MON/' -e 's/Tue/TUE/' -e 's/Wed/WED/' -e 's/Thu/THU/' -e 's/Fri/FRI/' -e 's/Sat/SAT/' -e 's/Sun/SUN/' -e 's/-[a-z]*$//g' ${SCRIPT_DIR}/tod_ton + time=$(sed -n 1p ${SCRIPT_DIR}/tod_ton) + image=$(sed -n 2p ${SCRIPT_DIR}/tod_ton) + # + if [ "${time}" = "TODAY" ]; then + sed -i 2s/${image}/$(test_image ${image})/ ${SCRIPT_DIR}/tod_ton + elif [ "${time}" = "TONIGHT" -o "${time}" = "OVERNIGHT" -o "${time}" = "EARLY AM" ]; then + sed -i 2s/${image}/$(test_image ${image})/ ${SCRIPT_DIR}/tod_ton + sed -i 3a- ${SCRIPT_DIR}/tod_ton + fi + # + for i in $(seq 7 5 22); do + image=$(sed -n "${i}"p ${SCRIPT_DIR}/tod_ton) + sed -i ${i}s/${image}/$(test_image ${image})/ ${SCRIPT_DIR}/tod_ton + done +fi + +## Next 5 days +if [ -s ${SCRIPT_DIR}/last_days_raw ]; then + sed -i '/feed-tabs/,/\.feed-tabs/!d' ${SCRIPT_DIR}/last_days_raw + egrep -i 'icon i-|cond|temp|Mon|Tue|Wed|Thu|Fri|Sat|Sun' ${SCRIPT_DIR}/last_days_raw > ${SCRIPT_DIR}/last_days + sed -i -e 's/^.*#">//g' -e 's/^.*icon i-//g' -e 's/^.*cond">//g' -e 's/^.*temp">//g' ${SCRIPT_DIR}/last_days + sed -i -e 's/Lo<\/span> /\n/g' -e 's/<\/a>.*$//g' -e 's/ "><.*$//g' -e 's/&#.*$//g' -e 's/teo//g' ${SCRIPT_DIR}/last_days + sed -i -e 's/.*$//g' -e 's/<\/span>//g' -e 's/\r$//g' -e 's/ i-alarm.*$//g' ${SCRIPT_DIR}/last_days + sed -i -e 's/Mon/MON/' -e 's/Tue/TUE/' -e 's/Wed/WED/' -e 's/Thu/THU/' -e 's/Fri/FRI/' -e 's/Sat/SAT/' -e 's/Sun/SUN/' -e 's/-[a-z]*$//g' ${SCRIPT_DIR}/last_days + # + for i in $(seq 7 5 22); do + image=$(sed -n "${i}"p ${SCRIPT_DIR}/last_days) + sed -i ${i}s/${image}/$(test_image ${image})/ ${SCRIPT_DIR}/last_days + done +fi + +#kill -CONT $(pidof conky) + diff --git a/.conky/cronograph/accuweather/curr_cond b/.conky/cronograph/accuweather/curr_cond new file mode 100644 index 0000000..f5d92e6 --- /dev/null +++ b/.conky/cronograph/accuweather/curr_cond @@ -0,0 +1,5 @@ +night +A +Clear +18 + diff --git a/.conky/cronograph/accuweather/curr_cond_raw b/.conky/cronograph/accuweather/curr_cond_raw new file mode 100644 index 0000000..9f2b26c --- /dev/null +++ b/.conky/cronograph/accuweather/curr_cond_raw @@ -0,0 +1,1646 @@ + + + + Shanghai Current Weather - AccuWeather Forecast for Shanghai China + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + + + + + + + + + + + + + +
+ +
+
+ + + + + + +
+ +
+
+
+ + + + + +
+ +
+ + + +
+
+ + + + + + + + + + + + +
+
+ +
+
+
+
+ +
+
+
+ + +
+ 1 - 5 of 45 days | All 45 days + +
+ + +
+ Next 5 Days + +
    +
  • +
    +
    +

    Today

    +

    May 10

    +
    +
    + Rain and drizzle this morning + 22°Lo 19° +
    + +
    + +
  • +
  • +
    +
    +

    Sun

    +

    May 11

    +
    +
    + Humid with heavy rain + 23°Lo 17° +
    + + more +
    + +
  • +
  • +
    +
    +

    Mon

    +

    May 12

    +
    +
    + Nice and warm with sunshine + 26°Lo 16° +
    + + more +
    + +
  • +
  • +
    +
    +

    Tue

    +

    May 13

    +
    +
    + Rather cloudy and warm + 26°Lo 18° +
    + + more +
    + +
  • +
  • +
    +
    +

    Wed

    +

    May 14

    +
    +
    + Showers around in the morning + 25°Lo 18° +
    + + more +
    + +
  • +
+
+ + + + +
+ + +
+
+
+
+
Light fog 19° RealFeel® 20°
+ +
+ +
+ +
+
+

N

+

E

+

S

+

W

+ +
+ + +
    +
  • Humidity: 88%
  • +
  • Pressure: 1014.00 mb
  • +
  • UV Index: 4
  • +
  • Cloud Cover: 20%
  • +
  • Ceiling: 549 m
  • +
  • Dew Point: 17° C
  • +
  • Visibility: 3 km
  • +
+ +
+ + +
17 km/h
+ +
+ +
+ +
+ + + + +
+
+

Sunrise/Sunset

+
+ + + Sunrise / Sunset Illustration + +

+ Rises at + 5:03 AM + with + + 13:36 + + of sunlight, then sets at + 6:39 PM +

+ +
+ + +
+
+

Moonrise/Moonset

+ Astronomy > +
+ + + Moonrise / Moonset Illustration + +

+ Rises at + 2:18 PM + with + 12:14 + of moolight, then sets at + 2:32 AM +

+ +
+ + + +
+
+

Temperature Summary - 10:58 AM

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Temp (°C)
Now19°
Yesterday21°
RealFeel®20°
RealFeel® Shade18°
Wind Chill19°
Dew Point17°
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Hi / Lo
Previous 6 Hours20°
 18°
Previous 12 Hours20°
 17°
Previous 24 Hours22°
 17°
+
+
+
+
+ +
+
+

Temperature History - May 10

+ more Historical Weather Data > + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 TodayNormalRecord5/10/2013
High22°23°N/A24°
Low19°16°N/A18°
+
+ + +
+
+

Precipitation Summary - 10:58 AM

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Amount (mm)
Previous 1 Hour0
Previous 3 Hours0
Previous 6 Hours1
Previous 9 Hours1
Previous 12 Hours1
Previous 18 Hours1
Previous 24 Hours1
+
+
+ +
+
+
+ +
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+ Top Story +

Shanghai Weather Report

+
+ + + +
+

Rainfall Tops 400 mm Near Hong Kong, More to Come

+
May 9, 2014; 10:05 PM ET
+

Hong Kong has already endured flooding rain, and more is on the way for this weekend. more >

+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + + + + +
+ + + +
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ + + + + + + +
+ +
+ + + + + + + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + diff --git a/.conky/cronograph/accuweather/last_days b/.conky/cronograph/accuweather/last_days new file mode 100644 index 0000000..75a56d9 --- /dev/null +++ b/.conky/cronograph/accuweather/last_days @@ -0,0 +1,25 @@ +WED +12 +Showers around in the morning +25 +17 +THU +d +Mostly cloudy +26 +18 +FRI +b +Partly sunny +23 +15 +SAT +i +Cooler with rain +17 +16 +SUN +i +Periods of rain +21 +17 diff --git a/.conky/cronograph/accuweather/last_days_raw b/.conky/cronograph/accuweather/last_days_raw new file mode 100644 index 0000000..6ac7def --- /dev/null +++ b/.conky/cronograph/accuweather/last_days_raw @@ -0,0 +1,82 @@ +
+ Previous 5 Days + Next 5 Days + +
    +
  • +
    +
    +

    Wed

    +

    May 14

    +
    +
    + Showers around in the morning + 25°Lo 17° +
    + +
    + +
  • +
  • +
    +
    +

    Thu

    +

    May 15

    +
    +
    + Mostly cloudy + 26°Lo 18° +
    + + more +
    + +
  • +
  • +
    +
    +

    Fri

    +

    May 16

    +
    +
    + Partly sunny + 23°Lo 15° +
    + + more +
    + +
  • +
  • +
    +
    +

    Sat

    +

    May 17

    +
    +
    + Cooler with rain + 17°Lo 16° +
    + + more +
    + +
  • +
  • +
    +
    +

    Sun

    +

    May 18

    +
    +
    + Periods of rain + 21°Lo 17° +
    + + more +
    + +
  • +
+
+ diff --git a/.conky/cronograph/accuweather/tod_ton b/.conky/cronograph/accuweather/tod_ton new file mode 100644 index 0000000..a839d7e --- /dev/null +++ b/.conky/cronograph/accuweather/tod_ton @@ -0,0 +1,25 @@ +TONIGHT +h +Rain and drizzle late +- +17 +SAT +e +Cloudy and breezy +21 +18 +SUN +i +Humid with heavy rain +23 +16 +MON +a +Nice and warm with sunshine +26 +16 +TUE +d +Rather cloudy and warm +26 +17 diff --git a/.conky/cronograph/accuweather/tod_ton_raw b/.conky/cronograph/accuweather/tod_ton_raw new file mode 100644 index 0000000..2976b86 --- /dev/null +++ b/.conky/cronograph/accuweather/tod_ton_raw @@ -0,0 +1,81 @@ +
+ Next 5 Days + +
    +
  • +
    +
    +

    Tonight

    +

    May 9

    +
    +
    + Rain and drizzle late + Lo 17° +
    + +
    + +
  • +
  • +
    +
    +

    Sat

    +

    May 10

    +
    +
    + Cloudy and breezy + 21°Lo 18° +
    + + more +
    + +
  • +
  • +
    +
    +

    Sun

    +

    May 11

    +
    +
    + Humid with heavy rain + 23°Lo 16° +
    + + more +
    + +
  • +
  • +
    +
    +

    Mon

    +

    May 12

    +
    +
    + Nice and warm with sunshine + 26°Lo 16° +
    + + more +
    + +
  • +
  • +
    +
    +

    Tue

    +

    May 13

    +
    +
    + Rather cloudy and warm + 26°Lo 17° +
    + + more +
    + +
  • +
+
+ diff --git a/.conky/cronograph/conky_start.sh b/.conky/cronograph/conky_start.sh new file mode 100755 index 0000000..98dbb27 --- /dev/null +++ b/.conky/cronograph/conky_start.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +CONKYRC="$HOME/.conky/cronograph/conkyrc" + +sleep 5 + +conky -d -c ${CONKYRC} "$@" + +exit 0 + diff --git a/.conky/cronograph/conkyrc b/.conky/cronograph/conkyrc new file mode 100644 index 0000000..3a54030 --- /dev/null +++ b/.conky/cronograph/conkyrc @@ -0,0 +1,89 @@ +# — Conky settings — # + +background yes + +update_interval 1 +total_run_times 0 +net_avg_samples 2 + +override_utf8_locale yes + +double_buffer yes +no_buffers yes + +text_buffer_size 2048 +imlib_cache_size 0 + +temperature_unit celsius + +# — Window specifications — # + +own_window_class Conky +own_window yes +own_window_type desktop +own_window_transparent yes +own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager + +border_inner_margin 0 +border_outer_margin 0 + +minimum_size 300 330 +maximum_width 300 + +alignment top_right + +gap_x 30 +gap_y 75 + + +# — Graphics settings — # +draw_shades no +draw_outline no +draw_borders no +draw_graph_borders no + +# — Text settings — # +use_xft yes +xftfont hooge 05_53:size=6 +xftalpha 0.5 + +default_color FFFFFF + +uppercase no +use_spacer right + +color0 white +color1 orange +color2 green + +# — Lua Load — # + +lua_load $HOME/.conky/cronograph/scripts/clock_rings.lua +lua_draw_hook_pre clock_rings +lua_load $HOME/.conky/cronograph/scripts/multi_rings.lua +lua_draw_hook_post main + +TEXT +${execi 600 sh $HOME/.conky/cronograph/accuweather/accuweather.sh} +#${voffset 29}${offset 120}BAT: +${voffset 29}${goto 109}GENTOO${goto 157}Linux +${voffset 17}${goto 65}${font hooge 05_53:size=12}${time %H:%M}${font}${goto 185}UPTIME: +${voffset 2}${goto 65}${time %a %d %b}${goto 185}${uptime} +${voffset 2}${goto 65}${time %Y} +${voffset -6}${goto 145}HD +${voffset 12}${alignc}${fs_free}/${fs_size} +${voffset 36}${goto 91}${cpu cpu0}%${goto 221}${memperc}% +${voffset 10}${goto 76}CPU${goto 205}MEM +${voffset 16}${goto 82}${font hooge 05_53:size=12}${execpi 600 sed -n '4p' $HOME/.conky/cronograph/accuweather/curr_cond}°C${font}${voffset -30}${goto 125}${font ConkyWeather:size=40}${execpi 600 sed -n '2p' $HOME/.conky/cronograph/accuweather/curr_cond}${font}${voffset -16}${goto 185}${execpi 600 sed -n '3p' $HOME/.conky/cronograph/accuweather/curr_cond}${voffset 12}${goto 185}${font ConkyWeather:size=20}${voffset 1}${goto 80}${execpi 600 sed -n '7p' $HOME/.conky/cronograph/accuweather/tod_ton}${goto 135}${execpi 600 sed -n '12p' $HOME/.conky/cronograph/accuweather/tod_ton}${goto 185}${execpi 600 sed -n '17p' $HOME/.conky/cronograph/accuweather/tod_ton}${font}${voffset 6}${goto 84}${execpi 600 sed -n '9p' $HOME/.conky/cronograph/accuweather/tod_ton}°/${execpi 600 sed -n '10p' $HOME/.conky/cronograph/accuweather/tod_ton}°${goto 140}${execpi 600 sed -n '14p' $HOME/.conky/cronograph/accuweather/tod_ton}°/${execpi 600 sed -n '15p' $HOME/.conky/cronograph/accuweather/tod_ton}°${goto 190}${execpi 600 sed -n '19p' $HOME/.conky/cronograph/accuweather/tod_ton}°/${execpi 600 sed -n '20p' $HOME/.conky/cronograph/accuweather/tod_ton}°${voffset 7}${goto 85}${execpi 600 sed -n '6p' $HOME/.conky/cronograph/accuweather/tod_ton}${goto 140}${execpi 600 sed -n '11p' $HOME/.conky/cronograph/accuweather/tod_ton}${goto 190}${execpi 600 sed -n '16p' $HOME/.conky/cronograph/accuweather/tod_ton} +${if_match ${battery_percent BAT0}>0}${if_match ${battery_percent BAT0}<=15}${image $HOME/.conky/cronograph/images/Red.png -p 129,18 -s 40x40}${endif}${endif} +${if_match ${battery_percent BAT0}>15}${if_match ${battery_percent BAT0}<=20}${image $HOME/.conky/cronograph/images/Orange.png -p 129,18 -s 40x40}${endif}${endif} +${if_match ${battery_percent BAT0}>20}${if_match ${battery_percent BAT0}<=35}${image $HOME/.conky/cronograph/images/Yellow.png -p 129,18 -s 40x40}${endif}${endif} +${if_match ${battery_percent BAT0}>35}${if_match ${battery_percent BAT0}<=100}${image $HOME/.conky/cronograph/images/Dark_Green.png -p 129,18 -s 40x40}${endif}${endif} +${execpi 30 cat $HOME/.conky/cronograph/scripts/blinkingLED} +## mpd ## +${if_mpd_playing}${voffset 6}${goto 10}${font Sans:size=8:bold}${mpd_artist}${font}${voffset -5}${font Sans:size=8} - ${mpd_title}${font} +${voffset 4}${goto 10}${mpd_bar 5,220}${alignr 10}${mpd_elapsed}/${mpd_length} +${else}${voffset 6}${goto 10}${font hooge 05_53:size=8}MPD: stopped${font} +${endif} + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=conkyrc: # diff --git a/.conky/cronograph/images/Blank.png b/.conky/cronograph/images/Blank.png new file mode 100644 index 0000000..a8adf65 Binary files /dev/null and b/.conky/cronograph/images/Blank.png differ diff --git a/.conky/cronograph/images/Blue.png b/.conky/cronograph/images/Blue.png new file mode 100644 index 0000000..2407cbe Binary files /dev/null and b/.conky/cronograph/images/Blue.png differ diff --git a/.conky/cronograph/images/Dark_Green.png b/.conky/cronograph/images/Dark_Green.png new file mode 100644 index 0000000..d40bcc4 Binary files /dev/null and b/.conky/cronograph/images/Dark_Green.png differ diff --git a/.conky/cronograph/images/Dark_Purple.png b/.conky/cronograph/images/Dark_Purple.png new file mode 100644 index 0000000..bb5da19 Binary files /dev/null and b/.conky/cronograph/images/Dark_Purple.png differ diff --git a/.conky/cronograph/images/Green.png b/.conky/cronograph/images/Green.png new file mode 100644 index 0000000..602ad43 Binary files /dev/null and b/.conky/cronograph/images/Green.png differ diff --git a/.conky/cronograph/images/Orange.png b/.conky/cronograph/images/Orange.png new file mode 100644 index 0000000..7574f9c Binary files /dev/null and b/.conky/cronograph/images/Orange.png differ diff --git a/.conky/cronograph/images/Pink.png b/.conky/cronograph/images/Pink.png new file mode 100644 index 0000000..6d2d973 Binary files /dev/null and b/.conky/cronograph/images/Pink.png differ diff --git a/.conky/cronograph/images/Purple.png b/.conky/cronograph/images/Purple.png new file mode 100644 index 0000000..e8c58e7 Binary files /dev/null and b/.conky/cronograph/images/Purple.png differ diff --git a/.conky/cronograph/images/Red.png b/.conky/cronograph/images/Red.png new file mode 100644 index 0000000..d2673e6 Binary files /dev/null and b/.conky/cronograph/images/Red.png differ diff --git a/.conky/cronograph/images/Yellow.png b/.conky/cronograph/images/Yellow.png new file mode 100644 index 0000000..8e2f62c Binary files /dev/null and b/.conky/cronograph/images/Yellow.png differ diff --git a/.conky/cronograph/scripts/blinkingLED b/.conky/cronograph/scripts/blinkingLED new file mode 100755 index 0000000..3f4c814 --- /dev/null +++ b/.conky/cronograph/scripts/blinkingLED @@ -0,0 +1,3 @@ +${image $HOME/.conky/cronograph/images/Blank.png -p 129, 241 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image $HOME/.conky/cronograph/images/Blue.png -p 129, 241 -s 40x40}${endif} +${image $HOME/.conky/cronograph/images/Blank.png -p 19, 129 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image $HOME/.conky/cronograph/images/Blue.png -p 19, 129 -s 40x40}${endif} +${image $HOME/.conky/cronograph/images/Blank.png -p 240, 129 -s 40x40}${if_match ${execi 1 num=$(date +%-S);rem=$(( num % 2 ));if [ $rem -eq 0 ] ; then echo 0 ; else echo 1 ; fi}==0}${image $HOME/.conky/cronograph/images/Blue.png -p 240, 129 -s 40x40}${endif} diff --git a/.conky/cronograph/scripts/clock_rings.lua b/.conky/cronograph/scripts/clock_rings.lua new file mode 100755 index 0000000..fb6a838 --- /dev/null +++ b/.conky/cronograph/scripts/clock_rings.lua @@ -0,0 +1,358 @@ +--[[ +Clock Rings by londonali1010 (2009) + +This script draws percentage meters as rings, and also draws clock hands if you want! It is fully customisable; all options are described in the script. This script is based off a combination of my clock.lua script and my rings.lua script. + +IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement near the end of the script uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num > 5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num > 3; conversely if you update Conky every 0.5s, you should use update_num > 10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error. + +To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua): + lua_load ~/scripts/clock_rings-v1.1.1.lua + lua_draw_hook_pre clock_rings + +Changelog: ++ v1.1.1 -- Fixed minor bug that caused the script to crash if conky_parse() returns a nil value (20.10.2009) ++ v1.1 -- Added colour option for clock hands (07.10.2009) ++ v1.0 -- Original release (30.09.2009) +]] + +settings_table = { + { + -- Edit this table to customise your rings. + -- You can create more rings simply by adding more elements to settings_table. + -- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'. + name='time', + -- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''. + arg='%I.%M', + -- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100. + max=12, + -- "bg_colour" is the colour of the base ring. + bg_colour=0xFFFFFF, + -- "bg_alpha" is the alpha value of the base ring. + bg_alpha=0.1, + -- "fg_colour" is the colour of the indicator part of the ring. + fg_colour=0xFFFFFF, + -- "fg_alpha" is the alpha value of the indicator part of the ring. + fg_alpha=0.5, + -- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window. + x=150, y=150, + -- "radius" is the radius of the ring. + radius=135, + -- "thickness" is the thickness of the ring, centred around the radius. + thickness=4, + -- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative. + start_angle=0, + -- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle. + end_angle=360 + }, + { + name='time', + arg='%M.%S', + max=60, + bg_colour=0xFFFFFF, + bg_alpha=0.1, + fg_colour=0xFFFFFF, + fg_alpha=0.5, + x=150, y=150, + radius=140, + thickness=4, + start_angle=0, + end_angle=360 + }, + { + name='time', + arg='%S', + max=60, + bg_colour=0xFFFFFF, + bg_alpha=0.1, + fg_colour=0xFFFFFF, + fg_alpha=0.5, + x=150, y=150, + radius=145, + thickness=4, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0x000000, + bg_alpha=0.1, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=150, y=150, + radius=66, + thickness=130, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0xFFFFFF, + bg_alpha=1.0, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=150, y=150, + radius=1, + thickness=10, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0xFFFFFF, + bg_alpha=1.0, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=85, y=150, + radius=30, + thickness=1, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0x000000, + bg_alpha=0.3, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=85, y=150, + radius=15, + thickness=27, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0xFFFFFF, + bg_alpha=1.0, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=85, y=150, + radius=1, + thickness=2, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0xFFFFFF, + bg_alpha=1.0, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=215, y=150, + radius=30, + thickness=1, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0x000000, + bg_alpha=0.3, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=215, y=150, + radius=15, + thickness=27, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0xFFFFFF, + bg_alpha=1.0, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=215, y=150, + radius=1, + thickness=2, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0xFFFFFF, + bg_alpha=1.0, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=150, y=75, + radius=25, + thickness=1, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0x000000, + bg_alpha=0.3, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=150, y=75, + radius=13, + thickness=22, + start_angle=0, + end_angle=360 + }, + { + name='', + arg='', + max=100, + bg_colour=0xFFFFFF, + bg_alpha=1.0, + fg_colour=0xFFFFFF, + fg_alpha=0.0, + x=150, y=75, + radius=1, + thickness=2, + start_angle=0, + end_angle=360 + }, + } + +-- Use these settings to define the origin and extent of your clock. + +clock_r=127 + +-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window. + +clock_x=150 +clock_y=150 + +-- Colour & alpha of the clock hands + +clock_colour=0xFFFFFF +clock_alpha=1 + +-- Do you want to show the seconds hand? + +show_seconds=true + +require 'cairo' + +function rgb_to_r_g_b(colour,alpha) + return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha +end + +function draw_ring(cr,t,pt) + local w,h=conky_window.width,conky_window.height + + local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle'] + local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha'] + + local angle_0=sa*(2*math.pi/360)-math.pi/2 + local angle_f=ea*(2*math.pi/360)-math.pi/2 + local t_arc=t*(angle_f-angle_0) + + -- Draw background ring + + cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f) + cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga)) + cairo_set_line_width(cr,ring_w) + cairo_stroke(cr) + + -- Draw indicator ring + + cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc) + cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga)) + cairo_stroke(cr) +end + +function draw_clock_hands(cr,xc,yc) + local secs,mins,hours,secs_arc,mins_arc,hours_arc + local xh,yh,xm,ym,xs,ys + + secs=os.date("%S") + mins=os.date("%M") + hours=os.date("%I") + + secs_arc=(2*math.pi/60)*secs + mins_arc=(2*math.pi/60)*mins+secs_arc/60 + hours_arc=(2*math.pi/12)*hours+mins_arc/12 + + -- Draw hour hand + + xh=xc+0.7*clock_r*math.sin(hours_arc) + yh=yc-0.7*clock_r*math.cos(hours_arc) + cairo_move_to(cr,xc,yc) + cairo_line_to(cr,xh,yh) + + cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND) + cairo_set_line_width(cr,5) + cairo_set_source_rgba(cr,rgb_to_r_g_b(clock_colour,clock_alpha)) + cairo_stroke(cr) + + -- Draw minute hand + + xm=xc+clock_r*math.sin(mins_arc) + ym=yc-clock_r*math.cos(mins_arc) + cairo_move_to(cr,xc,yc) + cairo_line_to(cr,xm,ym) + + cairo_set_line_width(cr,3) + cairo_stroke(cr) + + -- Draw seconds hand + + if show_seconds then + xs=xc+clock_r*math.sin(secs_arc) + ys=yc-clock_r*math.cos(secs_arc) + cairo_move_to(cr,xc,yc) + cairo_line_to(cr,xs,ys) + + cairo_set_line_width(cr,1) + cairo_stroke(cr) + end +end + +function conky_clock_rings() + local function setup_rings(cr,pt) + local str='' + local value=0 + + str=string.format('${%s %s}',pt['name'],pt['arg']) + str=conky_parse(str) + + value=tonumber(str) + if value == nil then value = 0 end + pct=value/pt['max'] + + draw_ring(cr,pct,pt) + end + + -- Check that Conky has been running for at least 5s + + if conky_window==nil then return end + local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height) + + local cr=cairo_create(cs) + + local updates=conky_parse('${updates}') + update_num=tonumber(updates) + + if update_num>5 then + for i in pairs(settings_table) do + setup_rings(cr,settings_table[i]) + end + end + + draw_clock_hands(cr,clock_x,clock_y) +end diff --git a/.conky/cronograph/scripts/multi_rings.lua b/.conky/cronograph/scripts/multi_rings.lua new file mode 100755 index 0000000..b9735b2 --- /dev/null +++ b/.conky/cronograph/scripts/multi_rings.lua @@ -0,0 +1,375 @@ +--============================================================================== +-- multi_rings.lua +-- +-- author : SLK +-- version : v2011011601 +-- license : Distributed under the terms of GNU GPL version 2 or later +-- +--============================================================================== + +require 'cairo' + +-------------------------------------------------------------------------------- +-- clock DATA +-- HOURS +clock_h = { + { + name='time', arg='%H', max_value=12, + x=150, y=150, + graph_radius=140, + graph_thickness=3, + graph_unit_angle=30, graph_unit_thickness=5, + graph_bg_colour=0xffffff, graph_bg_alpha=0.0, + graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0, + txt_radius=100, + txt_weight=1, txt_size=10.0, + txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0, + graduation_radius=125, + graduation_thickness=10, graduation_mark_thickness=2, + graduation_unit_angle=30, + graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0, + }, +} +-- MINUTES +clock_m = { + { + name='time', arg='%M', max_value=60, + x=150, y=150, + graph_radius=100, + graph_thickness=3, + graph_unit_angle=6, graph_unit_thickness=3, + graph_bg_colour=0xffffff, graph_bg_alpha=0.0, + graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0, + txt_radius=100, + txt_weight=0, txt_size=9.0, + txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0, + graduation_radius=57, + graduation_thickness=0, graduation_mark_thickness=2, + graduation_unit_angle=30, + graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0, + }, +} +-- SECONDS +clock_s = { + { + name='time', arg='%S', max_value=60, + x=150, y=150, + graph_radius=50, + graph_thickness=3, + graph_unit_angle=6, graph_unit_thickness=3, + graph_bg_colour=0xffffff, graph_bg_alpha=0.0, + graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0, + txt_radius=100, + txt_weight=0, txt_size=12.0, + txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0, + graduation_radius=0, + graduation_thickness=0, graduation_mark_thickness=0, + graduation_unit_angle=0, + graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0, + }, +} + +-------------------------------------------------------------------------------- +-- gauge DATA +gauge = { +{ + name='cpu', arg='cpu0', max_value=100, + x=85, y=150, + graph_radius=14, + graph_thickness=27, + graph_start_angle=0, + graph_unit_angle=3.5, graph_unit_thickness=3.0, + graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0, + graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0, + hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0, + txt_radius=1, + txt_weight=0, txt_size=8.0, + txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0, + graduation_radius=27, + graduation_thickness=4, graduation_mark_thickness=4, + graduation_unit_angle=30, + graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0, + caption='', + caption_weight=1, caption_size=8.0, + caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0, +}, +{ + name='memperc', arg='', max_value=100, + x=215, y=150, + graph_radius=14, + graph_thickness=27, + graph_start_angle=0, + graph_unit_angle=3.5, graph_unit_thickness=3.0, + graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0, + graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0, + hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0, + txt_radius=1, + txt_weight=0, txt_size=8.0, + txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0, + graduation_radius=27, + graduation_thickness=4, graduation_mark_thickness=4, + graduation_unit_angle=30, + graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0, + caption='', + caption_weight=1, caption_size=8.0, + caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0, +}, +{ + name='fs_used_perc', arg='/', max_value=100, + x=150, y=75, + graph_radius=10, + graph_thickness=23, + graph_start_angle=0, + graph_unit_angle=3.5, graph_unit_thickness=3.0, + graph_bg_colour=0xFFFFFF, graph_bg_alpha=0.0, + graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.0, + hand_fg_colour=0xFFFFFF, hand_fg_alpha=1.0, + txt_radius=1, + txt_weight=0, txt_size=8.0, + txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0, + graduation_radius=22, + graduation_thickness=4, graduation_mark_thickness=4, + graduation_unit_angle=30, + graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=1.0, + caption='', + caption_weight=1, caption_size=8.0, + caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.0, +}, +} + +------------------------------------------------------------------------------- +-- rgb_to_r_g_b +-- converts color in hexa to decimal +-- +function rgb_to_r_g_b(colour, alpha) + return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha +end + +------------------------------------------------------------------------------- +-- angle_to_position +-- convert degree to rad and rotate (0 degree is top/north) +-- +function angle_to_position(start_angle, current_angle) + local pos = current_angle + start_angle + return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) ) +end + +------------------------------------------------------------------------------- +-- draw_clock_ring +-- displays clock +-- +function draw_clock_ring(display, data, value) + local max_value = data['max_value'] + local x, y = data['x'], data['y'] + local graph_radius = data['graph_radius'] + local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness'] + local graph_unit_angle = data['graph_unit_angle'] + local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha'] + local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha'] + + -- background ring + cairo_arc(display, x, y, graph_radius, 0, 2 * math.pi) + cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha)) + cairo_set_line_width(display, graph_thickness) + cairo_stroke(display) + + -- arc of value + local val = (value % max_value) + local i = 1 + while i <= val do + cairo_arc(display, x, y, graph_radius,( ((graph_unit_angle * i) - graph_unit_thickness)*(2*math.pi/360) )-(math.pi/2),((graph_unit_angle * i) * (2*math.pi/360))-(math.pi/2)) + cairo_set_source_rgba(display,rgb_to_r_g_b(graph_fg_colour,graph_fg_alpha)) + cairo_stroke(display) + i = i + 1 + end + local angle = (graph_unit_angle * i) - graph_unit_thickness + + -- graduations marks + local graduation_radius = data['graduation_radius'] + local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness'] + local graduation_unit_angle = data['graduation_unit_angle'] + local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha'] + if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then + local nb_graduation = 360 / graduation_unit_angle + local i = 1 + while i <= nb_graduation do + cairo_set_line_width(display, graduation_thickness) + cairo_arc(display, x, y, graduation_radius, (((graduation_unit_angle * i)-(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2),(((graduation_unit_angle * i)+(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2)) + cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha)) + cairo_stroke(display) + cairo_set_line_width(display, graph_thickness) + i = i + 1 + end + end + + -- text + local txt_radius = data['txt_radius'] + local txt_weight, txt_size = data['txt_weight'], data['txt_size'] + local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha'] + local movex = txt_radius * (math.cos((angle * 2 * math.pi / 360)-(math.pi/2))) + local movey = txt_radius * (math.sin((angle * 2 * math.pi / 360)-(math.pi/2))) + cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight); + cairo_set_font_size (display, txt_size); + cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha)); + cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3); + cairo_show_text (display, value); + cairo_stroke (display); +end + +------------------------------------------------------------------------------- +-- draw_gauge_ring +-- displays gauges +-- +function draw_gauge_ring(display, data, value) + local max_value = data['max_value'] + local x, y = data['x'], data['y'] + local graph_radius = data['graph_radius'] + local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness'] + local graph_start_angle = data['graph_start_angle'] + local graph_unit_angle = data['graph_unit_angle'] + local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha'] + local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha'] + local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha'] + local graph_end_angle = (max_value * graph_unit_angle) % 360 + + -- background ring + cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle)) + cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha)) + cairo_set_line_width(display, graph_thickness) + cairo_stroke(display) + + -- arc of value + local val = value % (max_value + 1) + local start_arc = 0 + local stop_arc = 0 + local i = 1 + while i <= val do + start_arc = (graph_unit_angle * i) - graph_unit_thickness + stop_arc = (graph_unit_angle * i) + cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc)) + cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha)) + cairo_stroke(display) + i = i + 1 + end + local angle = start_arc + + -- hand + start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2) + stop_arc = (graph_unit_angle * val) + cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc)) + cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha)) + cairo_stroke(display) + + -- graduations marks + local graduation_radius = data['graduation_radius'] + local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness'] + local graduation_unit_angle = data['graduation_unit_angle'] + local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha'] + if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then + local nb_graduation = graph_end_angle / graduation_unit_angle + local i = 0 + while i < nb_graduation do + cairo_set_line_width(display, graduation_thickness) + start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2) + stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2) + cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc)) + cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha)) + cairo_stroke(display) + cairo_set_line_width(display, graph_thickness) + i = i + 1 + end + end + + -- text + local txt_radius = data['txt_radius'] + local txt_weight, txt_size = data['txt_weight'], data['txt_size'] + local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha'] + local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle)) + local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle)) + cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight) + cairo_set_font_size (display, txt_size) + cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha)) + cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3) + cairo_show_text (display, value) + cairo_stroke (display) + + -- caption + local caption = data['caption'] + local caption_weight, caption_size = data['caption_weight'], data['caption_size'] + local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha'] + local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2))) + local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2))) + cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight); + cairo_set_font_size (display, caption_size) + cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha)) + cairo_move_to (display, x + tox + 5, y + toy + 1) + -- bad hack but not enough time ! + if graph_start_angle < 105 then + cairo_move_to (display, x + tox - 30, y + toy + 1) + end + cairo_show_text (display, caption) + cairo_stroke (display) +end + +------------------------------------------------------------------------------- +-- go_clock_rings +-- loads data and displays clock +-- +function go_clock_rings(display) + local function load_clock_rings(display, data) + local str, value = '', 0 + str = string.format('${%s %s}',data['name'], data['arg']) + str = conky_parse(str) + value = tonumber(str) + draw_clock_ring(display, data, value) + end + + for i in pairs(clock_h) do + load_clock_rings(display, clock_h[i]) + end + for i in pairs(clock_m) do + load_clock_rings(display, clock_m[i]) + end + for i in pairs(clock_s) do + load_clock_rings(display, clock_s[i]) + end +end + +------------------------------------------------------------------------------- +-- go_gauge_rings +-- loads data and displays gauges +-- +function go_gauge_rings(display) + local function load_gauge_rings(display, data) + local str, value = '', 0 + str = string.format('${%s %s}',data['name'], data['arg']) + str = conky_parse(str) + value = tonumber(str) + draw_gauge_ring(display, data, value) + end + + for i in pairs(gauge) do + load_gauge_rings(display, gauge[i]) + end +end + +------------------------------------------------------------------------------- +-- MAIN +function conky_main() + if conky_window == nil then + return + end + + local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height) + local display = cairo_create(cs) + + local updates = conky_parse('${updates}') + update_num = tonumber(updates) + + if update_num > 5 then + go_clock_rings(display) + go_gauge_rings(display) + end + +end + -- cgit v1.2.2