From 5d3e23efe20ef50f4d6721ef9473fc311d5d21a3 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Mon, 13 Jul 2015 22:56:52 +0200 Subject: [PATCH] Volume widget --- VolumeWidget/volume-icons/1.png | Bin 0 -> 233 bytes VolumeWidget/volume-icons/2.png | Bin 0 -> 242 bytes VolumeWidget/volume-icons/3.png | Bin 0 -> 248 bytes VolumeWidget/volume-icons/4.png | Bin 0 -> 255 bytes VolumeWidget/volume-icons/5.png | Bin 0 -> 260 bytes VolumeWidget/volume-icons/6.png | Bin 0 -> 270 bytes VolumeWidget/volume-icons/7.png | Bin 0 -> 273 bytes VolumeWidget/volume-icons/8.png | Bin 0 -> 282 bytes VolumeWidget/volume-icons/9.png | Bin 0 -> 286 bytes VolumeWidget/volume.lua | 35 ++++++++++++++++++++++++++++++++ 10 files changed, 35 insertions(+) create mode 100644 VolumeWidget/volume-icons/1.png create mode 100644 VolumeWidget/volume-icons/2.png create mode 100644 VolumeWidget/volume-icons/3.png create mode 100644 VolumeWidget/volume-icons/4.png create mode 100644 VolumeWidget/volume-icons/5.png create mode 100644 VolumeWidget/volume-icons/6.png create mode 100644 VolumeWidget/volume-icons/7.png create mode 100644 VolumeWidget/volume-icons/8.png create mode 100644 VolumeWidget/volume-icons/9.png create mode 100644 VolumeWidget/volume.lua diff --git a/VolumeWidget/volume-icons/1.png b/VolumeWidget/volume-icons/1.png new file mode 100644 index 0000000000000000000000000000000000000000..3f4e6b452e3d2dbf02c4a748a4870311179e2352 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkc#TlDjldw@ccC9V-A&iT2ysd*&~&PAz-C8;S2 z<(VZJ3hti10pX2&;y^`#o-U3d6}R4AR1{)R;9+(=^#8vMOY_ldZ&r1!x)TLdfC6|< zSl{~gd&ZHN&)YazoDEonc@7Hr7ywx?RSmBhCi1d~nf~4N5+vm5>gTe~DWM4fzbHI) literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume-icons/2.png b/VolumeWidget/volume-icons/2.png new file mode 100644 index 0000000000000000000000000000000000000000..9a488c79ae469bb55e38258f824f6cdcac3b91bc GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkd=<(FAo4*-QEOI#yLobz*YQ}ap~oQqNuOHxx5 z$}>wc6x=<11Hv2m#DR*UJY5_^DsH{KvXPTPfydQx|BnBs3YobB9e2D=p6Hsiyx z9?X5i7Z$23@0Yaqd8xKQPj{RCxmHDqCeF454mF7;#Tf~3#qqNoc5ui^A3UNC67qEQ Kb6Mw<&;$T5DL&!= literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume-icons/3.png b/VolumeWidget/volume-icons/3.png new file mode 100644 index 0000000000000000000000000000000000000000..a1bfb30af8e01010129ffd0a1afd5801b17c30e3 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkd=L9ZKc3Q$P0#5JPCIX^cyHLrxhxhOTUBsE2$ zJhLQ2!QIn0AiR-J9H=P4)5S5Q;?~DiFY7 zcg@#;(5oMnXKEh5Yru3c!(^_7bX!7>`o+%8i5zVSO^OmtoNWmlY9I%J!GUnGWfDAU SD;=ZGfcT!SelF{r5}E*JRYBVT literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume-icons/4.png b/VolumeWidget/volume-icons/4.png new file mode 100644 index 0000000000000000000000000000000000000000..8f111109e26ed5ba841716744c08a816b257ed69 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkd=T;K$T)j%Q164!_l=ltB<)VvY~=c3falGGH1 z^30M91$R&1fbd2>aiF4fPZ!6Kid%25+~j0X;9+%C{&v6U%>jANiZdY!Ybw_=0+qmk z!&Hl}i8E)OZg)S@e{h$*wnS@NXK^COv2QA~EX3Oq`281wxNQkdiV{tnZ3!G|Aa{Ym afl#%BHUfG-ZeH;L@jYGrT-G@yGywpte?~0; literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume-icons/5.png b/VolumeWidget/volume-icons/5.png new file mode 100644 index 0000000000000000000000000000000000000000..613cb4a8da1755f6b6d2894294a260a8f1375a5e GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkd=TIHl2ra&Rd64!_l=ltB<)VvY~=c3falGGH1 z^30M91$R&1fbd2>aiF3cPZ!6Kid%259OPtB;9)uF@@D_j8;$y+JjSvoW_1G}wd$?2arBr^|}%IWsl6U>$JU({Kg$kCS2q$ttE*_Obe e267x290(Viq#|OLqp)rZi0|p@=d#Wzp$PyGvq?h$ literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume-icons/6.png b/VolumeWidget/volume-icons/6.png new file mode 100644 index 0000000000000000000000000000000000000000..1defc8a16ac11a481900ee5fca22517eeab3c4fa GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkeo*~c@r-@ynFG`LC%)r3XIaJrQ~?1E z){9=Zr>Duut35ioedfQLQ7qbNGcCm15^U@{W7W>Ja=M-NG%3{cF|eEGBK-W2z?;V) rF3&*$9|IO=gM$J*2U(b5W@)4{OI(n!t2&wQ0}}Fd^>bP0l+XkK|3ph) literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume-icons/7.png b/VolumeWidget/volume-icons/7.png new file mode 100644 index 0000000000000000000000000000000000000000..8207899ba5b2712a076098aa569e6d1044cb5793 GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkeouCi3VGEhje#5JPCIX^cyHLrxhxhOTUBsE2$ zJhLQ2!QIn0AiR-J9H^+$)5S5Q;?~rl|>*)90zM-($q1sL?T z2){XbCPvQa(J9^CnpuVshR%=fshw;0RGOqwXy+p|(WUcqBAc_2>bZ8wp8J!5Vm!^Y rb3lR;Jk63k&4~s;#FJ(KGp`{?E!0rP?XRkGJV?mX)z4*}Q$iB}Eu~Bj literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume-icons/8.png b/VolumeWidget/volume-icons/8.png new file mode 100644 index 0000000000000000000000000000000000000000..423f21365dd53555b21cd3fe423c7c502a17d396 GIT binary patch literal 282 zcmeAS@N?(olHy`uVBq!ia0vp^IY8{r!3HEB@h-9eQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~JFkeo{OhxJi-AItC9V-A&iT2ysd*&~&PAz-C8;S2 z<(VZJ3hti10pX2&;y^`Bo-U3d6}R4AImpYP$l>Z}`0c(?bkoHbjOEK%>MGVU0+j&4 zfxdz!Ya`?3$NMAp)tBFj;t4xb&}7_s`{Zo?$u25^k7{P9D0K=wKdd6?ImJR=t~3iEBiObAE1aYF-J0b5UwyNotBh zd1gt5g1e`0KzJjcI8afWr;B4q#jUs3Hu5qk@~}Aeyx5;AJaOL_L5Vc4gr~x58G&jT z7(O^xG!>_$)g9~VcsDakaLtT|oZrseo@F7PCS=$-{ojKaiKdw@!p{#0oKXP^wk4=t zJhIb(#kf=LT&v;?Pm@ADo`d)1fEDl@WN|iN5#~84;9~$b8b~w*sohsl3G>~srw1hD M>FVdQ&MBb@0DG5KaR2}S literal 0 HcmV?d00001 diff --git a/VolumeWidget/volume.lua b/VolumeWidget/volume.lua new file mode 100644 index 0000000..e800c32 --- /dev/null +++ b/VolumeWidget/volume.lua @@ -0,0 +1,35 @@ +local wibox = require("wibox") +local awful = require("awful") + +volume_widget = wibox.widget.textbox() +volume_icon = wibox.widget.imagebox() + +function update_volume(widget, icon) + local fd = io.popen("amixer -D pulse sget Master") + local status = fd:read("*all") + fd:close() + + local volume = string.match(status, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + + status = string.match(status, "%[(o[^%]]*)%]") + + if (volume >= 0 and volume < 10) then volumeLevel=1 + elseif (volume >= 10 and volume < 20) then volumeLevel=2 + elseif (volume >= 20 and volume < 30) then volumeLevel=3 + elseif (volume >= 30 and volume < 40) then volumeLevel=4 + elseif (volume >= 40 and volume < 50) then volumeLevel=5 + elseif (volume >= 50 and volume < 60) then volumeLevel=6 + elseif (volume >= 60 and volume < 70) then volumeLevel=7 + elseif (volume >= 70 and volume < 80) then volumeLevel=8 + elseif (volume >= 80 and volume <= 100) then volumeLevel=9 + end + + icon:set_image("/home/pashik/.config/awesome/volume-icons/" .. volumeLevel .. ".png") +end + +update_volume(volume_widget, volume_icon) + +mytimer = timer({ timeout = 0.2 }) +mytimer:connect_signal("timeout", function () update_volume(volume_widget, volume_icon) end) +mytimer:start() \ No newline at end of file