From 75c195782d7d4ad7f4707e0ac53dd1439ae344e5 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 30 Mar 2019 17:42:59 -0400 Subject: [PATCH 01/31] volumearc - externalize config --- volumearc-widget/README.md | 49 ++++++++++++------- volumearc-widget/volumearc.lua | 89 +++++++++++++++++++++------------- 2 files changed, 87 insertions(+), 51 deletions(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 702b486..79f519d 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -2,24 +2,39 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using arcchart: -![screenshot](out.gif) - -Supports: - - scroll up - increase volume, - - scroll down - decrease volume, - - left click - mute/unmute. +![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} ## Installation -Clone repo, include widget and use it in **rc.lua**: +1. Clone this repo under **~/.config/awesome/** -```lua -require("volumearc") -... -s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - ... - volumearc_widget, - ... -``` + ```bash + git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/ + ``` + +1. Require volumearc widget at the beginning of **rc.lua**: + + ```lua + local volumearc_widget = require("awesome-wm-widgets.volumearc-widget.volumearc") + ``` + +1. Add widget to the tasklist: + + ```lua + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + --[[default]] + volumearc_widget(), + --[[or customized]] + volumearc_widget({ + main_color = '#0000ff', + mute_color = '#ff0000', + path_to_icon = '/usr/share/icons/Arc/actions/symbolic/view-grid-symbolic.svg', + thickness = 5, + height = 25 + }), + + ... + ``` \ No newline at end of file diff --git a/volumearc-widget/volumearc.lua b/volumearc-widget/volumearc.lua index 63500bc..4a91cd3 100644 --- a/volumearc-widget/volumearc.lua +++ b/volumearc-widget/volumearc.lua @@ -21,47 +21,68 @@ local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg" -local icon = { - id = "icon", - image = PATH_TO_ICON, - resize = true, - widget = wibox.widget.imagebox, -} +local widget = {} -local volumearc = wibox.widget { - icon, - max_value = 1, - thickness = 2, - start_angle = 4.71238898, -- 2pi*3/4 - forced_height = 18, - forced_width = 18, - bg = "#ffffff11", - paddings = 2, - widget = wibox.container.arcchart -} +local function worker(args) -local update_graphic = function(widget, stdout, _, _, _) - local mute = string.match(stdout, "%[(o%D%D?)%]") - local volume = string.match(stdout, "(%d?%d?%d)%%") - volume = tonumber(string.format("% 3d", volume)) + local args = args or {} - widget.value = volume / 100; - widget.colors = mute == 'off' and { beautiful.widget_red } - or { beautiful.widget_main_color } + local main_color = args.main_color or beautiful.widget_main_color + local mute_color = args.mute_color or beautiful.widget_red + local path_to_icon = args.path_to_icon or PATH_TO_ICON + local thickness = args.thickness or 2 + local height = args.height or 18 -end + local get_volume_cmd = args.get_volume_cmd or GET_VOLUME_CMD + local inc_volume_cmd = args.inc_volume_cmd or INC_VOLUME_CMD + local dec_volume_cmd = args.dec_volume_cmd or DEC_VOLUME_CMD + local tog_volume_cmd = args.tog_volume_cmd or TOG_VOLUME_CMD -volumearc:connect_signal("button::press", function(_, _, _, button) - if (button == 4) then awful.spawn(INC_VOLUME_CMD, false) - elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD, false) - elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD, false) + + local icon = { + id = "icon", + image = path_to_icon, + resize = true, + widget = wibox.widget.imagebox, + } + + local volumearc = wibox.widget { + icon, + max_value = 1, + thickness = thickness, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = height, + forced_width = height, + bg = "#ffffff11", + paddings = 2, + widget = wibox.container.arcchart + } + + local update_graphic = function(widget, stdout, _, _, _) + local mute = string.match(stdout, "%[(o%D%D?)%]") + local volume = string.match(stdout, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + + widget.value = volume / 100; + widget.colors = mute == 'off' + and { mute_color } + or { main_color } end - spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) - update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + volumearc:connect_signal("button::press", function(_, _, _, button) + if (button == 4) then awful.spawn(inc_volume_cmd, false) + elseif (button == 5) then awful.spawn(dec_volume_cmd, false) + elseif (button == 1) then awful.spawn(tog_volume_cmd, false) + end + + spawn.easy_async(get_volume_cmd, function(stdout, stderr, exitreason, exitcode) + update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + end) end) -end) -watch(GET_VOLUME_CMD, 1, update_graphic, volumearc) + watch(get_volume_cmd, 1, update_graphic, volumearc) -return volumearc \ No newline at end of file + return volumearc +end + +return setmetatable(widget, { __call = function(_, ...) return worker(...) end }) From c06b09703181954387d0e2dddca9680e3c36e21c Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 30 Mar 2019 17:42:59 -0400 Subject: [PATCH 02/31] volumearc - externalize config --- volumearc-widget/README.md | 49 ++++++++++++------- volumearc-widget/volumearc.lua | 89 +++++++++++++++++++++------------- 2 files changed, 87 insertions(+), 51 deletions(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 702b486..79f519d 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -2,24 +2,39 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using arcchart: -![screenshot](out.gif) - -Supports: - - scroll up - increase volume, - - scroll down - decrease volume, - - left click - mute/unmute. +![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} ## Installation -Clone repo, include widget and use it in **rc.lua**: +1. Clone this repo under **~/.config/awesome/** -```lua -require("volumearc") -... -s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - ... - volumearc_widget, - ... -``` + ```bash + git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/ + ``` + +1. Require volumearc widget at the beginning of **rc.lua**: + + ```lua + local volumearc_widget = require("awesome-wm-widgets.volumearc-widget.volumearc") + ``` + +1. Add widget to the tasklist: + + ```lua + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + --[[default]] + volumearc_widget(), + --[[or customized]] + volumearc_widget({ + main_color = '#0000ff', + mute_color = '#ff0000', + path_to_icon = '/usr/share/icons/Arc/actions/symbolic/view-grid-symbolic.svg', + thickness = 5, + height = 25 + }), + + ... + ``` \ No newline at end of file diff --git a/volumearc-widget/volumearc.lua b/volumearc-widget/volumearc.lua index 63500bc..4a91cd3 100644 --- a/volumearc-widget/volumearc.lua +++ b/volumearc-widget/volumearc.lua @@ -21,47 +21,68 @@ local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg" -local icon = { - id = "icon", - image = PATH_TO_ICON, - resize = true, - widget = wibox.widget.imagebox, -} +local widget = {} -local volumearc = wibox.widget { - icon, - max_value = 1, - thickness = 2, - start_angle = 4.71238898, -- 2pi*3/4 - forced_height = 18, - forced_width = 18, - bg = "#ffffff11", - paddings = 2, - widget = wibox.container.arcchart -} +local function worker(args) -local update_graphic = function(widget, stdout, _, _, _) - local mute = string.match(stdout, "%[(o%D%D?)%]") - local volume = string.match(stdout, "(%d?%d?%d)%%") - volume = tonumber(string.format("% 3d", volume)) + local args = args or {} - widget.value = volume / 100; - widget.colors = mute == 'off' and { beautiful.widget_red } - or { beautiful.widget_main_color } + local main_color = args.main_color or beautiful.widget_main_color + local mute_color = args.mute_color or beautiful.widget_red + local path_to_icon = args.path_to_icon or PATH_TO_ICON + local thickness = args.thickness or 2 + local height = args.height or 18 -end + local get_volume_cmd = args.get_volume_cmd or GET_VOLUME_CMD + local inc_volume_cmd = args.inc_volume_cmd or INC_VOLUME_CMD + local dec_volume_cmd = args.dec_volume_cmd or DEC_VOLUME_CMD + local tog_volume_cmd = args.tog_volume_cmd or TOG_VOLUME_CMD -volumearc:connect_signal("button::press", function(_, _, _, button) - if (button == 4) then awful.spawn(INC_VOLUME_CMD, false) - elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD, false) - elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD, false) + + local icon = { + id = "icon", + image = path_to_icon, + resize = true, + widget = wibox.widget.imagebox, + } + + local volumearc = wibox.widget { + icon, + max_value = 1, + thickness = thickness, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = height, + forced_width = height, + bg = "#ffffff11", + paddings = 2, + widget = wibox.container.arcchart + } + + local update_graphic = function(widget, stdout, _, _, _) + local mute = string.match(stdout, "%[(o%D%D?)%]") + local volume = string.match(stdout, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + + widget.value = volume / 100; + widget.colors = mute == 'off' + and { mute_color } + or { main_color } end - spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) - update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + volumearc:connect_signal("button::press", function(_, _, _, button) + if (button == 4) then awful.spawn(inc_volume_cmd, false) + elseif (button == 5) then awful.spawn(dec_volume_cmd, false) + elseif (button == 1) then awful.spawn(tog_volume_cmd, false) + end + + spawn.easy_async(get_volume_cmd, function(stdout, stderr, exitreason, exitcode) + update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + end) end) -end) -watch(GET_VOLUME_CMD, 1, update_graphic, volumearc) + watch(get_volume_cmd, 1, update_graphic, volumearc) -return volumearc \ No newline at end of file + return volumearc +end + +return setmetatable(widget, { __call = function(_, ...) return worker(...) end }) From 768b979f87fb374b607075651591425bbcda9dd6 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 30 Mar 2019 17:42:59 -0400 Subject: [PATCH 03/31] volumearc - externalize config --- volumearc-widget/README.md | 49 ++++++++++++------- volumearc-widget/volumearc.lua | 89 +++++++++++++++++++++------------- 2 files changed, 87 insertions(+), 51 deletions(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 702b486..79f519d 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -2,24 +2,39 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using arcchart: -![screenshot](out.gif) - -Supports: - - scroll up - increase volume, - - scroll down - decrease volume, - - left click - mute/unmute. +![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} ## Installation -Clone repo, include widget and use it in **rc.lua**: +1. Clone this repo under **~/.config/awesome/** -```lua -require("volumearc") -... -s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - ... - volumearc_widget, - ... -``` + ```bash + git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/ + ``` + +1. Require volumearc widget at the beginning of **rc.lua**: + + ```lua + local volumearc_widget = require("awesome-wm-widgets.volumearc-widget.volumearc") + ``` + +1. Add widget to the tasklist: + + ```lua + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + --[[default]] + volumearc_widget(), + --[[or customized]] + volumearc_widget({ + main_color = '#0000ff', + mute_color = '#ff0000', + path_to_icon = '/usr/share/icons/Arc/actions/symbolic/view-grid-symbolic.svg', + thickness = 5, + height = 25 + }), + + ... + ``` \ No newline at end of file diff --git a/volumearc-widget/volumearc.lua b/volumearc-widget/volumearc.lua index 63500bc..4a91cd3 100644 --- a/volumearc-widget/volumearc.lua +++ b/volumearc-widget/volumearc.lua @@ -21,47 +21,68 @@ local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg" -local icon = { - id = "icon", - image = PATH_TO_ICON, - resize = true, - widget = wibox.widget.imagebox, -} +local widget = {} -local volumearc = wibox.widget { - icon, - max_value = 1, - thickness = 2, - start_angle = 4.71238898, -- 2pi*3/4 - forced_height = 18, - forced_width = 18, - bg = "#ffffff11", - paddings = 2, - widget = wibox.container.arcchart -} +local function worker(args) -local update_graphic = function(widget, stdout, _, _, _) - local mute = string.match(stdout, "%[(o%D%D?)%]") - local volume = string.match(stdout, "(%d?%d?%d)%%") - volume = tonumber(string.format("% 3d", volume)) + local args = args or {} - widget.value = volume / 100; - widget.colors = mute == 'off' and { beautiful.widget_red } - or { beautiful.widget_main_color } + local main_color = args.main_color or beautiful.widget_main_color + local mute_color = args.mute_color or beautiful.widget_red + local path_to_icon = args.path_to_icon or PATH_TO_ICON + local thickness = args.thickness or 2 + local height = args.height or 18 -end + local get_volume_cmd = args.get_volume_cmd or GET_VOLUME_CMD + local inc_volume_cmd = args.inc_volume_cmd or INC_VOLUME_CMD + local dec_volume_cmd = args.dec_volume_cmd or DEC_VOLUME_CMD + local tog_volume_cmd = args.tog_volume_cmd or TOG_VOLUME_CMD -volumearc:connect_signal("button::press", function(_, _, _, button) - if (button == 4) then awful.spawn(INC_VOLUME_CMD, false) - elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD, false) - elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD, false) + + local icon = { + id = "icon", + image = path_to_icon, + resize = true, + widget = wibox.widget.imagebox, + } + + local volumearc = wibox.widget { + icon, + max_value = 1, + thickness = thickness, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = height, + forced_width = height, + bg = "#ffffff11", + paddings = 2, + widget = wibox.container.arcchart + } + + local update_graphic = function(widget, stdout, _, _, _) + local mute = string.match(stdout, "%[(o%D%D?)%]") + local volume = string.match(stdout, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + + widget.value = volume / 100; + widget.colors = mute == 'off' + and { mute_color } + or { main_color } end - spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) - update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + volumearc:connect_signal("button::press", function(_, _, _, button) + if (button == 4) then awful.spawn(inc_volume_cmd, false) + elseif (button == 5) then awful.spawn(dec_volume_cmd, false) + elseif (button == 1) then awful.spawn(tog_volume_cmd, false) + end + + spawn.easy_async(get_volume_cmd, function(stdout, stderr, exitreason, exitcode) + update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + end) end) -end) -watch(GET_VOLUME_CMD, 1, update_graphic, volumearc) + watch(get_volume_cmd, 1, update_graphic, volumearc) -return volumearc \ No newline at end of file + return volumearc +end + +return setmetatable(widget, { __call = function(_, ...) return worker(...) end }) From 93ef029bdbcc1a1f6de927b1351d7169ba9b698e Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 13 Apr 2019 20:51:54 -0400 Subject: [PATCH 04/31] update volumearc readme --- volumearc-widget/README.md | 24 +++++++++++++++++++++--- volumearc-widget/custom.png | Bin 0 -> 9424 bytes volumearc-widget/volumearc.lua | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 volumearc-widget/custom.png diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 79f519d..5bd8e83 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -4,6 +4,24 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm ![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +```lua +volumearc_widget({ + main_color = '#af13f7', + mute_color = '#ff0000', + path_to_icon = '/usr/share/icons/Papirus-Dark/symbolic/status/audio-volume-high-symbolic.svg', + thickness = 5, + height = 25 +}) +``` + +Above config results in following widget: + +![custom](./custom.png) + ## Installation 1. Clone this repo under **~/.config/awesome/** @@ -29,12 +47,12 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm volumearc_widget(), --[[or customized]] volumearc_widget({ - main_color = '#0000ff', + main_color = '#af13f7', mute_color = '#ff0000', - path_to_icon = '/usr/share/icons/Arc/actions/symbolic/view-grid-symbolic.svg', + path_to_icon = '/usr/share/icons/Papirus-Dark/symbolic/status/audio-volume-high-symbolic.svg', thickness = 5, height = 25 }), ... - ``` \ No newline at end of file + ``` diff --git a/volumearc-widget/custom.png b/volumearc-widget/custom.png new file mode 100644 index 0000000000000000000000000000000000000000..f1873452f33ce862bdbe3fdf48f070f504717acb GIT binary patch literal 9424 zcmV;>Brn^EP)^geT+3kzw6g4W zVT-yJ&9D@;9T25K69uA7kr1Fl0vRfEDwRrVOiiy|z2Tegy=U0{$N9eV&b#kbEJ+|) zcJ`|E*7x1-4EyZ;+r!!C+yu|O_!aQtqto>T=l8DMm~S1|r`*5dOSeyc(lJ|Ov@zD& z7n-~O$aL(`;pfs_K3{x1Uv!$;`ljQ*yuN>S{16ERpb$xtCf3-zC|*L<_lc}7pG)@_ z7oM)}{M^;YZ$zeNX(Oa)h$dNxn+gQS<|uRB>V4Jl0%rCvn#@Djm`#6LCN_>Ud?<;ue&*`7N`Zr+*PJ134o z+X*StBq6cL0J1DIrpwGfKxSW}XQLMdp04QrRL!>HC*K+W{O4OAw`d068JyNy>nux? zBnizBF-ek_qTY*#UU)na(8crD#7`b;ZTqK@k1!0p&g80<^;+%7(W!o(=XpU$G758v zQYVimBs%}~S50hO?~Fyl`J>0~`=@_dw&i)Rze?xDjytw3GYI03zULRqUjL3i|C^JX zw?eg%)?|K9GaHf=ob z+N+*<`0>Vtqv7FQpT5O^SiNQQ*{^-oi4=VAEw?)70H8Us;zxezrd{9uPHm*M;rw&I z`jJ0n=SYax{pv66d+^cz+U-$GK55GqUWx%t*JF1uvq#`WxYY|ZM!Pd>Hh-Us5w8!tTXz$1_M=jS(Ec<$U+ zjs}73-TsiuvaH#dJACxvuiUP(^qOCJ=b;@>j;vm_?XN#$hSd!uyz`TvN$T}eFWkD6 zH+>x~q2I z^FVE+wRFH|pKd{7NJ*ATrG%77$d0WsMr%X@SX2mn-u%<5O&gi{-dk?{_jYW$@%ZbJ zbhrQTvp@Bg@bHRPUAANAuE%yhIXcpsott;g0xaMO5#i)$=9xps_UyarT|W=Z0B~@}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+U(i%tr0kWRu|8j3W+t#C5@PDzVBxC>>yd!{# z)I3~Rq}qx>S9HLHj@iFoV1XSo5Xvl>+qD;ZeJKf)B zNE2~UCb5*_W)-%VA}=0oSp+Y|@dEOM(Cv<%?Tlm21~AmKlhoLKMycf*`3F1*7ObeLyj$NrINOL?Z6LJl zm=F+El6XFdnXR)70D_uhqm5QGM3#8s6M@MXN-4!rTEom4iKKLVXlBEkF5mc}cVv^}y#q&Axb(>JnG{B9 z9V@e}X(W*-8f5Ikp=>O78Xf~wLf*1LkfXFR=D*UoqTrCeR8SZ%IdnwC(rH;*SkYW{ z)+XniNE2iLYr^=kvw`SBU!W6#$qmZ^u>%XMv%~jMVR6m}QrMBKRY2M4v2`%s>^}J9 zq3=A{8XMJG`}VzFuPjTIrR3NEaUByVof)k&q1T)*wD{V0mSxU46eN_Ci4sbpAphC| z3Q7_Qy^hXYEt4gjz^{RvDH?3dtRw8VMHJ^wLF6*KT7_;*u7Gp_<`ZFpPN zIX5_iPm;k4u80Tr?eA@S)U6&JP3r~Qkw()oPqao!k^lx>lvqnevxWxz=rQ*gz0V&n z##^(sHg^U~!^{eWsAsv=#m;>YT`Oj0WbiQ~s4Ad`qrzsqVT{cvR=_|p+K!*MC9BuU z`L2^>BuOOJ);3Tz(k7~uC0JKjEwW71n-%92f(0zemvMMLjf-F5^3Yj&GQ-hk4WpFH zFEHNz_yu~$ztmGAA`qFmepeUcoaUJrzx=|)A@_>-|5{MV2OyOjZg}1J51q}rEVV|% z%nV8*V%UEL7*X^}*3tus_%jUCz6BGKqF)weS(238>mB&(e<_>7IhR{)N{v!rY5pIK Wpls~|uXn2e0000 Date: Sat, 30 Mar 2019 17:42:59 -0400 Subject: [PATCH 05/31] volumearc - externalize config --- volumearc-widget/README.md | 49 ++++++++++++------- volumearc-widget/volumearc.lua | 89 +++++++++++++++++++++------------- 2 files changed, 87 insertions(+), 51 deletions(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 702b486..79f519d 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -2,24 +2,39 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using arcchart: -![screenshot](out.gif) - -Supports: - - scroll up - increase volume, - - scroll down - decrease volume, - - left click - mute/unmute. +![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} ## Installation -Clone repo, include widget and use it in **rc.lua**: +1. Clone this repo under **~/.config/awesome/** -```lua -require("volumearc") -... -s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - ... - volumearc_widget, - ... -``` + ```bash + git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/ + ``` + +1. Require volumearc widget at the beginning of **rc.lua**: + + ```lua + local volumearc_widget = require("awesome-wm-widgets.volumearc-widget.volumearc") + ``` + +1. Add widget to the tasklist: + + ```lua + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + --[[default]] + volumearc_widget(), + --[[or customized]] + volumearc_widget({ + main_color = '#0000ff', + mute_color = '#ff0000', + path_to_icon = '/usr/share/icons/Arc/actions/symbolic/view-grid-symbolic.svg', + thickness = 5, + height = 25 + }), + + ... + ``` \ No newline at end of file diff --git a/volumearc-widget/volumearc.lua b/volumearc-widget/volumearc.lua index 63500bc..4a91cd3 100644 --- a/volumearc-widget/volumearc.lua +++ b/volumearc-widget/volumearc.lua @@ -21,47 +21,68 @@ local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg" -local icon = { - id = "icon", - image = PATH_TO_ICON, - resize = true, - widget = wibox.widget.imagebox, -} +local widget = {} -local volumearc = wibox.widget { - icon, - max_value = 1, - thickness = 2, - start_angle = 4.71238898, -- 2pi*3/4 - forced_height = 18, - forced_width = 18, - bg = "#ffffff11", - paddings = 2, - widget = wibox.container.arcchart -} +local function worker(args) -local update_graphic = function(widget, stdout, _, _, _) - local mute = string.match(stdout, "%[(o%D%D?)%]") - local volume = string.match(stdout, "(%d?%d?%d)%%") - volume = tonumber(string.format("% 3d", volume)) + local args = args or {} - widget.value = volume / 100; - widget.colors = mute == 'off' and { beautiful.widget_red } - or { beautiful.widget_main_color } + local main_color = args.main_color or beautiful.widget_main_color + local mute_color = args.mute_color or beautiful.widget_red + local path_to_icon = args.path_to_icon or PATH_TO_ICON + local thickness = args.thickness or 2 + local height = args.height or 18 -end + local get_volume_cmd = args.get_volume_cmd or GET_VOLUME_CMD + local inc_volume_cmd = args.inc_volume_cmd or INC_VOLUME_CMD + local dec_volume_cmd = args.dec_volume_cmd or DEC_VOLUME_CMD + local tog_volume_cmd = args.tog_volume_cmd or TOG_VOLUME_CMD -volumearc:connect_signal("button::press", function(_, _, _, button) - if (button == 4) then awful.spawn(INC_VOLUME_CMD, false) - elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD, false) - elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD, false) + + local icon = { + id = "icon", + image = path_to_icon, + resize = true, + widget = wibox.widget.imagebox, + } + + local volumearc = wibox.widget { + icon, + max_value = 1, + thickness = thickness, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = height, + forced_width = height, + bg = "#ffffff11", + paddings = 2, + widget = wibox.container.arcchart + } + + local update_graphic = function(widget, stdout, _, _, _) + local mute = string.match(stdout, "%[(o%D%D?)%]") + local volume = string.match(stdout, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + + widget.value = volume / 100; + widget.colors = mute == 'off' + and { mute_color } + or { main_color } end - spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) - update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + volumearc:connect_signal("button::press", function(_, _, _, button) + if (button == 4) then awful.spawn(inc_volume_cmd, false) + elseif (button == 5) then awful.spawn(dec_volume_cmd, false) + elseif (button == 1) then awful.spawn(tog_volume_cmd, false) + end + + spawn.easy_async(get_volume_cmd, function(stdout, stderr, exitreason, exitcode) + update_graphic(volumearc, stdout, stderr, exitreason, exitcode) + end) end) -end) -watch(GET_VOLUME_CMD, 1, update_graphic, volumearc) + watch(get_volume_cmd, 1, update_graphic, volumearc) -return volumearc \ No newline at end of file + return volumearc +end + +return setmetatable(widget, { __call = function(_, ...) return worker(...) end }) From c40075136423a5602d27325a1366c371acfe801c Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 13 Apr 2019 20:51:54 -0400 Subject: [PATCH 06/31] update volumearc readme --- volumearc-widget/README.md | 24 +++++++++++++++++++++--- volumearc-widget/custom.png | Bin 0 -> 9424 bytes volumearc-widget/volumearc.lua | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 volumearc-widget/custom.png diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 79f519d..5bd8e83 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -4,6 +4,24 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm ![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +```lua +volumearc_widget({ + main_color = '#af13f7', + mute_color = '#ff0000', + path_to_icon = '/usr/share/icons/Papirus-Dark/symbolic/status/audio-volume-high-symbolic.svg', + thickness = 5, + height = 25 +}) +``` + +Above config results in following widget: + +![custom](./custom.png) + ## Installation 1. Clone this repo under **~/.config/awesome/** @@ -29,12 +47,12 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm volumearc_widget(), --[[or customized]] volumearc_widget({ - main_color = '#0000ff', + main_color = '#af13f7', mute_color = '#ff0000', - path_to_icon = '/usr/share/icons/Arc/actions/symbolic/view-grid-symbolic.svg', + path_to_icon = '/usr/share/icons/Papirus-Dark/symbolic/status/audio-volume-high-symbolic.svg', thickness = 5, height = 25 }), ... - ``` \ No newline at end of file + ``` diff --git a/volumearc-widget/custom.png b/volumearc-widget/custom.png new file mode 100644 index 0000000000000000000000000000000000000000..f1873452f33ce862bdbe3fdf48f070f504717acb GIT binary patch literal 9424 zcmV;>Brn^EP)^geT+3kzw6g4W zVT-yJ&9D@;9T25K69uA7kr1Fl0vRfEDwRrVOiiy|z2Tegy=U0{$N9eV&b#kbEJ+|) zcJ`|E*7x1-4EyZ;+r!!C+yu|O_!aQtqto>T=l8DMm~S1|r`*5dOSeyc(lJ|Ov@zD& z7n-~O$aL(`;pfs_K3{x1Uv!$;`ljQ*yuN>S{16ERpb$xtCf3-zC|*L<_lc}7pG)@_ z7oM)}{M^;YZ$zeNX(Oa)h$dNxn+gQS<|uRB>V4Jl0%rCvn#@Djm`#6LCN_>Ud?<;ue&*`7N`Zr+*PJ134o z+X*StBq6cL0J1DIrpwGfKxSW}XQLMdp04QrRL!>HC*K+W{O4OAw`d068JyNy>nux? zBnizBF-ek_qTY*#UU)na(8crD#7`b;ZTqK@k1!0p&g80<^;+%7(W!o(=XpU$G758v zQYVimBs%}~S50hO?~Fyl`J>0~`=@_dw&i)Rze?xDjytw3GYI03zULRqUjL3i|C^JX zw?eg%)?|K9GaHf=ob z+N+*<`0>Vtqv7FQpT5O^SiNQQ*{^-oi4=VAEw?)70H8Us;zxezrd{9uPHm*M;rw&I z`jJ0n=SYax{pv66d+^cz+U-$GK55GqUWx%t*JF1uvq#`WxYY|ZM!Pd>Hh-Us5w8!tTXz$1_M=jS(Ec<$U+ zjs}73-TsiuvaH#dJACxvuiUP(^qOCJ=b;@>j;vm_?XN#$hSd!uyz`TvN$T}eFWkD6 zH+>x~q2I z^FVE+wRFH|pKd{7NJ*ATrG%77$d0WsMr%X@SX2mn-u%<5O&gi{-dk?{_jYW$@%ZbJ zbhrQTvp@Bg@bHRPUAANAuE%yhIXcpsott;g0xaMO5#i)$=9xps_UyarT|W=Z0B~@} zlaJnZ2LRml>6?9n^RK=7lrvA?{)I1{DBh)w`l`(vx8M5ZqT9Xrx;H#_+c$!aA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5Xvl>+qD;ZeJKf)B zNE2~UCb5*_W)-%VA}=0oSp+Y|@dEOM(Cv<%?Tlm21~AmKlhoLKMycf*`3F1*7ObeLyj$NrINOL?Z6LJl zm=F+El6XFdnXR)70D_uhqm5QGM3#8s6M@MXN-4!rTEom4iKKLVXlBEkF5mc}cVv^}y#q&Axb(>JnG{B9 z9V@e}X(W*-8f5Ikp=>O78Xf~wLf*1LkfXFR=D*UoqTrCeR8SZ%IdnwC(rH;*SkYW{ z)+XniNE2iLYr^=kvw`SBU!W6#$qmZ^u>%XMv%~jMVR6m}QrMBKRY2M4v2`%s>^}J9 zq3=A{8XMJG`}VzFuPjTIrR3NEaUByVof)k&q1T)*wD{V0mSxU46eN_Ci4sbpAphC| z3Q7_Qy^hXYEt4gjz^{RvDH?3dtRw8VMHJ^wLF6*KT7_;*u7Gp_<`ZFpPN zIX5_iPm;k4u80Tr?eA@S)U6&JP3r~Qkw()oPqao!k^lx>lvqnevxWxz=rQ*gz0V&n z##^(sHg^U~!^{eWsAsv=#m;>YT`Oj0WbiQ~s4Ad`qrzsqVT{cvR=_|p+K!*MC9BuU z`L2^>BuOOJ);3Tz(k7~uC0JKjEwW71n-%92f(0zemvMMLjf-F5^3Yj&GQ-hk4WpFH zFEHNz_yu~$ztmGAA`qFmepeUcoaUJrzx=|)A@_>-|5{MV2OyOjZg}1J51q}rEVV|% z%nV8*V%UEL7*X^}*3tus_%jUCz6BGKqF)weS(238>mB&(e<_>7IhR{)N{v!rY5pIK Wpls~|uXn2e0000 Date: Sat, 13 Apr 2019 20:53:50 -0400 Subject: [PATCH 07/31] Update README.md --- volumearc-widget/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 5bd8e83..38e7e05 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -2,7 +2,7 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using arcchart: -![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} +![screenshot](out.gif) ## Customization From aa6f0363ad3385f9cd68efc45429948669de5422 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 13 Apr 2019 20:56:13 -0400 Subject: [PATCH 08/31] update readme --- volumearc-widget/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 5bd8e83..38e7e05 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -2,7 +2,7 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using arcchart: -![screenshot]({{'/assets/img/screenshots/volumearc-widget.gif' | relative_url }}){:.center-image} +![screenshot](out.gif) ## Customization From ed8bd0a96a353d309ca5d9750d8ce0919db6a7c8 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 13 Apr 2019 22:44:47 -0400 Subject: [PATCH 09/31] update volumebar widget --- volumebar-widget/README.md | 61 ++++++++++++++++++++---- volumebar-widget/custom.png | Bin 0 -> 9126 bytes volumebar-widget/volumebar.lua | 84 +++++++++++++++++++-------------- 3 files changed, 100 insertions(+), 45 deletions(-) create mode 100644 volumebar-widget/custom.png diff --git a/volumebar-widget/README.md b/volumebar-widget/README.md index d6b9117..92beee2 100644 --- a/volumebar-widget/README.md +++ b/volumebar-widget/README.md @@ -9,21 +9,62 @@ Supports - scroll down - decrease volume, - left click - mute/unmute. - ## Installation + ## Customization - Clone repo, include widget and use it in **rc.lua**: + It is possible to customize widget by providing a table with all or some of the following config parameters: ```lua -local volumebar_widget = require("awesome-wm-widgets.volumebar-widget.volumebar") -... -s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - ... - volumebar_widget, - ... + volumebar_widget({ + main_color = '#af13f7', + mute_color = '#ff0000', + width = 80, + shape = 'rounded_bar', -- octogon, hexagon, powerline, etc + -- bar's height = wibar's height minus 2x margins + margins = 8 +}) ``` +Above config results in following widget: + +![custom](./custom.png) + + + ## Installation + +1. Clone this repo under **~/.config/awesome/** + + ```bash + git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/ + ``` + +1. Require volumebar widget at the beginning of **rc.lua**: + + ```lua + local volumebar_widget = require("awesome-wm-widgets.volumebar-widget.volumebar") + ``` + +1. Add widget to the tasklist: + + ```lua + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + --[[default]] + volumebar_widget(), + --[[or customized]] + volumebar_widget({ + main_color = '#af13f7', + mute_color = '#ff0000', + width = 80, + shape = 'rounded_bar', -- octogon, hexagon, powerline, etc + -- bar's height = wibar's height minus 2x margins + margins = 8 + }), + + ... + ``` + ## Troubleshooting If the bar is not showing up, try to decrease top or bottom margin - widget uses hardcoded margins for vertical alignment, so if your wibox is too small then bar is simply hidden by the margins. diff --git a/volumebar-widget/custom.png b/volumebar-widget/custom.png new file mode 100644 index 0000000000000000000000000000000000000000..d86143b31166ea93b79acae4a15a4e3f0affbf57 GIT binary patch literal 9126 zcmV;XBU#*uP)S_9f00003b3#c}2nYz< z;ZNWI000?uMObuGZ)S9NVRB^vXKrt8Wi4}Ka%E+1b7*gL?*qR+001BWNkl&7gf9SyF6aVH+=!9m^(G2*waWVgv>kE^tz0VJSiti&I6Y zii4p7gv10KJ9e;HEbu0z1@9I{^;-P>G!=SS(b&t zrFZJptMA?K-tNz1ly4*1#Qmnc7-bXpoAP3mP26wFi%~XlzbP+9*{tXMV-zI1AM=PTa+gAd*Ew-5Zy ztTceaBr4Ug>ID`-aAWY5V^TfR=i);S*f&j5_zQpdVcTx+z4YSs zx|y;F&OejpJW;zI3;{q{>l?TJV%h7x?kBIme1WoYR&ZWNqZI@ zHkdIaTNc_Fr8N=?OYq)1he!Y+zw?FU`)z0J6Or3LcEdOH)MYELe*ty)M=r*g=Yspi zCyyL|?BG@J`cV)8fWrqK`s$500l*hO^wD_3CD&Yi+PP=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Q1k% zTeb!9)x|sS`;$)}`i1w0qsPsbS;vh?7>aL#hXAFqQ<% zcef$XKs!hYn`!k;i7Z=&{;wbE`$*OSCOg7$=M;HIq^vDA$jllrtB2r zbLCG>(V(g%s6kViFns**9iK5_e3v;uF@H-UoqmWeJ79M25KkzhP@kxxC1x07`M5kgReTA@}#=!I+V;v#k2 z`^2aWqLhNkYnKsT*4lQvEdcSA*}x1jj~`c+)~w-D$WBv?h=vq1dtq&D|B1uRu|*(c z9}qDR0FP5-S-T0v*;)UbDPR(p^9(25-wk>&9Q1ZY-%eVjH z56y|0J<_*j!OY4tcFMl5r&v7a+7!ofS??7&;PR9MCV6Huao$3Xf!wiE?J`F#C>4&L z@C4g0zZgKQ6Y&ncBR-Woj`{rsc$**#K*58?&B%w59uP88csZ6hEfd){Z+hz5a kw^vK6ZnjMEB#%7*9|Y+Kp{YsN;Q#;t07*qoM6N<$g8ppToB#j- literal 0 HcmV?d00001 diff --git a/volumebar-widget/volumebar.lua b/volumebar-widget/volumebar.lua index 9fd6a99..c1fcf71 100644 --- a/volumebar-widget/volumebar.lua +++ b/volumebar-widget/volumebar.lua @@ -9,6 +9,7 @@ ------------------------------------------------- local awful = require("awful") +local beautiful = require("beautiful") local gears = require("gears") local spawn = require("awful.spawn") local watch = require("awful.widget.watch") @@ -19,48 +20,61 @@ local INC_VOLUME_CMD = 'amixer -D pulse sset Master 5%+' local DEC_VOLUME_CMD = 'amixer -D pulse sset Master 5%-' local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' -local bar_color = "#74aeab" -local mute_color = "#ff0000" -local background_color = "#3a3a3a" +local widget = {} -local volumebar_widget = wibox.widget { - max_value = 1, - forced_width = 50, - paddings = 0, - border_width = 0.5, - color = bar_color, - background_color = background_color, - shape = gears.shape.bar, - clip = true, - margins = { - top = 10, - bottom = 10, - }, - widget = wibox.widget.progressbar -} +local function worker(args) -local update_graphic = function(widget, stdout, _, _, _) - local mute = string.match(stdout, "%[(o%D%D?)%]") - local volume = string.match(stdout, "(%d?%d?%d)%%") - volume = tonumber(string.format("% 3d", volume)) + local args = args or {} - widget.value = volume / 100; - widget.color = mute == "off" and mute_color - or bar_color + local main_color = args.main_color or beautiful.widget_main_color + local mute_color = args.mute_color or beautiful.widget_red + local width = args.width or 50 + local shape = args.shape or 'bar' + local margins = args.margins or 10 -end + local volumebar_widget = wibox.widget { + max_value = 1, + forced_width = width, + color = main_color, + background_color = '#ffffff11', + shape = gears.shape[shape], + margins = { + top = margins, + bottom = margins, + }, + widget = wibox.widget.progressbar + } + + local update_graphic = function(widget, stdout, _, _, _) + local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off] + local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%) + volume = tonumber(string.format("% 3d", volume)) + + widget.value = volume / 100; + widget.color = mute == "off" + and mute_color + or main_color -volumebar_widget:connect_signal("button::press", function(_,_,_,button) - if (button == 4) then awful.spawn(INC_VOLUME_CMD) - elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD) - elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD) end - spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) - update_graphic(volumebar_widget, stdout, stderr, exitreason, exitcode) + volumebar_widget:connect_signal("button::press", function(_, _, _, button) + if (button == 4) then + awful.spawn(INC_VOLUME_CMD) + elseif (button == 5) then + awful.spawn(DEC_VOLUME_CMD) + elseif (button == 1) then + awful.spawn(TOG_VOLUME_CMD) + end + + spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) + update_graphic(volumebar_widget, stdout, stderr, exitreason, exitcode) + end) end) -end) -watch(GET_VOLUME_CMD, 1, update_graphic, volumebar_widget) + watch(GET_VOLUME_CMD, 1, update_graphic, volumebar_widget) + + return volumebar_widget +end + +return setmetatable(widget, { __call = function(_, ...) return worker(...) end }) -return volumebar_widget \ No newline at end of file From 8e92a8541bba98132ce92307400f458bda65295b Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 13 Apr 2019 22:46:16 -0400 Subject: [PATCH 10/31] add mouse control info to readme --- volumearc-widget/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 38e7e05..f791d3a 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -4,6 +4,11 @@ Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm ![screenshot](out.gif) +Supports + - scroll up - increase volume, + - scroll down - decrease volume, + - left click - mute/unmute. + ## Customization It is possible to customize widget by providing a table with all or some of the following config parameters: From d0cbdc1647f793ea9b2922970022794e92202d4a Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sun, 14 Apr 2019 20:07:15 -0400 Subject: [PATCH 11/31] Add table with config to the readme --- volumearc-widget/README.md | 16 ++++++++++++++-- volumearc-widget/volumearc.lua | 5 ++--- volumebar-widget/README.md | 25 +++++++++++++++++++------ volumebar-widget/volumebar.lua | 19 ++++++++++++------- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index f791d3a..aac7e90 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -13,11 +13,24 @@ Supports It is possible to customize widget by providing a table with all or some of the following config parameters: +| Name | Default | Description | +|---|---|---| +| `main_color` | `beautiful.fg_normal` | Color of the arc | +| `mute_color` | `beautiful.fg_urgent` | Color of the arc when mute | +| `path_to_icon` | /usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg | Path to the icon | +| `thickness` | 2 | The arc thickness | +| `height` | `beautiful.fg_normal` | Widget height | +| `get_volume_cmd` | `amixer -D pulse sget Master` | Get current volume level | +| `inc_volume_cmd` | `amixer -D pulse sset Master 5%+` | Increase volume level | +| `dec_volume_cmd` | `amixer -D pulse sset Master 5%-` | Descrease volume level | +| `tog_volume_cmd` | `amixer -D pulse sset Master toggle` | Mute / unmute | + +### Example: + ```lua volumearc_widget({ main_color = '#af13f7', mute_color = '#ff0000', - path_to_icon = '/usr/share/icons/Papirus-Dark/symbolic/status/audio-volume-high-symbolic.svg', thickness = 5, height = 25 }) @@ -54,7 +67,6 @@ Above config results in following widget: volumearc_widget({ main_color = '#af13f7', mute_color = '#ff0000', - path_to_icon = '/usr/share/icons/Papirus-Dark/symbolic/status/audio-volume-high-symbolic.svg', thickness = 5, height = 25 }), diff --git a/volumearc-widget/volumearc.lua b/volumearc-widget/volumearc.lua index 5fbf3dd..62b18ab 100644 --- a/volumearc-widget/volumearc.lua +++ b/volumearc-widget/volumearc.lua @@ -27,8 +27,8 @@ local function worker(args) local args = args or {} - local main_color = args.main_color or beautiful.widget_main_color - local mute_color = args.mute_color or beautiful.widget_red + local main_color = args.main_color or beautiful.fg_color + local mute_color = args.mute_color or beautiful.fg_urgent local path_to_icon = args.path_to_icon or PATH_TO_ICON local thickness = args.thickness or 2 local height = args.height or 18 @@ -38,7 +38,6 @@ local function worker(args) local dec_volume_cmd = args.dec_volume_cmd or DEC_VOLUME_CMD local tog_volume_cmd = args.tog_volume_cmd or TOG_VOLUME_CMD - local icon = { id = "icon", image = path_to_icon, diff --git a/volumebar-widget/README.md b/volumebar-widget/README.md index 92beee2..35169b7 100644 --- a/volumebar-widget/README.md +++ b/volumebar-widget/README.md @@ -9,17 +9,30 @@ Supports - scroll down - decrease volume, - left click - mute/unmute. - ## Customization - - It is possible to customize widget by providing a table with all or some of the following config parameters: +## Customization +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `main_color` | `beautiful.fg_normal` | Color of the bar | +| `mute_color` | `beautiful.fg_urgent` | Color of the bar when mute | +| `width` | 50 | The bar width | +| `shape` | `bar` | [gears.shape](https://awesomewm.org/doc/api/libraries/gears.shape.html), could be `octogon`, `hexagon`, `powerline`, etc | +| `margin` | `10` | Top and bottom margin (if your wibar is 22 px high, bar will be 2 px (22 - 2*10)) | +| `get_volume_cmd` | `amixer -D pulse sget Master` | Get current volume level | +| `inc_volume_cmd` | `amixer -D pulse sset Master 5%+` | Increase volume level | +| `dec_volume_cmd` | `amixer -D pulse sset Master 5%-` | Descrease volume level | +| `tog_volume_cmd` | `amixer -D pulse sset Master toggle` | Mute / unmute | + +### Example: + ```lua volumebar_widget({ main_color = '#af13f7', mute_color = '#ff0000', width = 80, - shape = 'rounded_bar', -- octogon, hexagon, powerline, etc - -- bar's height = wibar's height minus 2x margins + shape = 'rounded_bar', margins = 8 }) ``` @@ -29,7 +42,7 @@ Above config results in following widget: ![custom](./custom.png) - ## Installation +## Installation 1. Clone this repo under **~/.config/awesome/** diff --git a/volumebar-widget/volumebar.lua b/volumebar-widget/volumebar.lua index c1fcf71..18e0f40 100644 --- a/volumebar-widget/volumebar.lua +++ b/volumebar-widget/volumebar.lua @@ -26,12 +26,17 @@ local function worker(args) local args = args or {} - local main_color = args.main_color or beautiful.widget_main_color - local mute_color = args.mute_color or beautiful.widget_red + local main_color = args.main_color or beautiful.fg_normal + local mute_color = args.mute_color or beautiful.fg_urgent local width = args.width or 50 local shape = args.shape or 'bar' local margins = args.margins or 10 + local get_volume_cmd = args.get_volume_cmd or GET_VOLUME_CMD + local inc_volume_cmd = args.inc_volume_cmd or INC_VOLUME_CMD + local dec_volume_cmd = args.dec_volume_cmd or DEC_VOLUME_CMD + local tog_volume_cmd = args.tog_volume_cmd or TOG_VOLUME_CMD + local volumebar_widget = wibox.widget { max_value = 1, forced_width = width, @@ -59,19 +64,19 @@ local function worker(args) volumebar_widget:connect_signal("button::press", function(_, _, _, button) if (button == 4) then - awful.spawn(INC_VOLUME_CMD) + awful.spawn(inc_volume_cmd) elseif (button == 5) then - awful.spawn(DEC_VOLUME_CMD) + awful.spawn(dec_volume_cmd) elseif (button == 1) then - awful.spawn(TOG_VOLUME_CMD) + awful.spawn(tog_volume_cmd) end - spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) + spawn.easy_async(get_volume_cmd, function(stdout, stderr, exitreason, exitcode) update_graphic(volumebar_widget, stdout, stderr, exitreason, exitcode) end) end) - watch(GET_VOLUME_CMD, 1, update_graphic, volumebar_widget) + watch(get_volume_cmd, 1, update_graphic, volumebar_widget) return volumebar_widget end From 429e6eb54a5bab17d7adba8956fcbc0a63257ed5 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Thu, 2 May 2019 21:35:30 -0400 Subject: [PATCH 12/31] external config for brightness and brightnessarc --- brightness-widget/README.md | 35 +++++++++++- brightness-widget/brightness.lua | 75 ++++++++++++++++--------- brightnessarc-widget/README.md | 63 ++++++++++++++++----- brightnessarc-widget/brightnessarc.lua | 78 ++++++++++++++++---------- 4 files changed, 177 insertions(+), 74 deletions(-) diff --git a/brightness-widget/README.md b/brightness-widget/README.md index 5d592b6..7b05d2f 100644 --- a/brightness-widget/README.md +++ b/brightness-widget/README.md @@ -2,6 +2,29 @@ This widget represents current brightness level: ![Brightness widget](./br-wid-1.png) +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `get_brightness_cmd` | `light -G` | Get current screen brightness | +| `inc_brightness_cmd` | `light -A 5` | Increase brightness | +| `dec_brightness_cmd` | `light -U 5`| Decrease brightness | +| `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon | +| `font` | `Play 9` | Font | + +### Example: + +```lua +brightness_widget({ + get_brightness_cmd = 'xbacklight -get', + inc_brightness_cmd = 'xbacklight -inc 5', + dec_brightness_cmd = 'xbacklight -dec 5' +}) +``` + + ## Installation First you need to get the current brightness level. There are two options: @@ -29,8 +52,6 @@ First you need to get the current brightness level. There are two options: 49.18 ``` -Depending on the chosen option change `GET_BRIGHTNESS_CMD` variable in **brightness.lua**. - Then clone this repo under **~/.config/awesome/**: ```bash @@ -50,7 +71,15 @@ s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, ... - brightness_widget, + -- default + brightness_widget(), + -- or customized + brightness_widget({ + get_brightness_cmd = 'xbacklight -get', + inc_brightness_cmd = 'xbacklight -inc 5', + dec_brightness_cmd = 'xbacklight -dec 5' + }) + } ... ``` diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua index 075765c..28e7015 100644 --- a/brightness-widget/brightness.lua +++ b/brightness-widget/brightness.lua @@ -5,7 +5,7 @@ -- https://github.com/streetturtle/awesome-wm-widgets/tree/master/brightness-widget -- @author Pavel Makhov --- @copyright 2017 Pavel Makhov +-- @copyright 2017-2019 Pavel Makhov ------------------------------------------------- local wibox = require("wibox") @@ -17,36 +17,55 @@ local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get" local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5" local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 5" -local brightness_text = wibox.widget.textbox() -brightness_text:set_font('Play 9') +local widget = {} -local brightness_icon = wibox.widget { - { - image = PATH_TO_ICON, - resize = false, - widget = wibox.widget.imagebox, - }, - top = 3, - widget = wibox.container.margin -} +local function worker(args) -local brightness_widget = wibox.widget { - brightness_icon, - brightness_text, - layout = wibox.layout.fixed.horizontal, -} + local args = args or {} -local update_widget = function(widget, stdout, stderr, exitreason, exitcode) - local brightness_level = tonumber(string.format("%.0f", stdout)) - widget:set_text(" " .. brightness_level .. "%") -end, + local get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD + local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD + local dec_brightness_cmd = args.dec_brightness_cmd or DEC_BRIGHTNESS_CMD + local path_to_icon = args.path_to_icon or PATH_TO_ICON + local font = args.font or 'Play 9' -brightness_widget:connect_signal("button::press", function(_,_,_,button) - if (button == 4) then spawn(INC_BRIGHTNESS_CMD, false) - elseif (button == 5) then spawn(DEC_BRIGHTNESS_CMD, false) - end -end) + local brightness_text = wibox.widget.textbox() + brightness_text:set_font(font) -watch(GET_BRIGHTNESS_CMD, 1, update_widget, brightness_text) + local brightness_icon = wibox.widget { + { + image = path_to_icon, + resize = false, + widget = wibox.widget.imagebox, + }, + top = 3, + widget = wibox.container.margin + } -return brightness_widget + widget = wibox.widget { + brightness_icon, + brightness_text, + layout = wibox.layout.fixed.horizontal, + } + + local update_widget = function(widget, stdout, _, _, _) + local brightness_level = tonumber(string.format("%.0f", stdout)) + widget:set_text(" " .. brightness_level .. "%") + end, + + widget:connect_signal("button::press", function(_, _, _, button) + if (button == 4) then + spawn(inc_brightness_cmd, false) + elseif (button == 5) then + spawn(dec_brightness_cmd, false) + end + end) + + watch(get_brightness_cmd, 1, update_widget, brightness_text) + + return widget +end + +return setmetatable(widget, { __call = function(_, ...) + return worker(...) +end }) diff --git a/brightnessarc-widget/README.md b/brightnessarc-widget/README.md index fa123c1..d122d3a 100644 --- a/brightnessarc-widget/README.md +++ b/brightnessarc-widget/README.md @@ -1,12 +1,32 @@ # Brightness widget -![Brightness widget](./br-wid-1.png) +This widget represents current brightness level: ![Brightness widget](./br-wid-1.png) + +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `get_brightness_cmd` | `light -G` | Get current screen brightness | +| `inc_brightness_cmd` | `light -A 5` | Increase brightness | +| `dec_brightness_cmd` | `light -U 5`| Decrease brightness | +| `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon | + +### Example: + +```lua +brightnessarc_widget({ + get_brightness_cmd = 'xbacklight -get', + inc_brightness_cmd = 'xbacklight -inc 5', + dec_brightness_cmd = 'xbacklight -dec 5' +}) +``` -This widget represents current brightness level. ## Installation -Firstly you need to get the current brightness level. There are two options: +First you need to get the current brightness level. There are two options: - using `xbacklight` command (depending on your video card (I guess) it may or may not work) @@ -30,19 +50,36 @@ Firstly you need to get the current brightness level. There are two options: light -G 49.18 ``` -Depending on the chosen option change `GET_BRIGHTNESS_CMD` variable in **brightness.lua**. -Then in **rc.lua** add the import on top of the file and then add widget to the wibox: +Then clone this repo under **~/.config/awesome/**: + +```bash +git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/ +``` + +Require widget at the beginning of **rc.lua**: ```lua -require("awesome-wm-widgets.brightness-widget.brightness") -... --- Add widgets to the wibox -s.mywibox:setup { -... -{ -- Right widgets -... -brightness_widget +local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness") +``` + +Add widget to the tasklist: + +```lua +s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + -- default + brightnessarc_widget(), + -- or customized + brightnessarc_widget({ + get_brightness_cmd = 'xbacklight -get', + inc_brightness_cmd = 'xbacklight -inc 5', + dec_brightness_cmd = 'xbacklight -dec 5' + }) + } + ... ``` ## Controls diff --git a/brightnessarc-widget/brightnessarc.lua b/brightnessarc-widget/brightnessarc.lua index 7633218..dac08e4 100644 --- a/brightnessarc-widget/brightnessarc.lua +++ b/brightnessarc-widget/brightnessarc.lua @@ -2,7 +2,7 @@ -- Brightness Widget for Awesome Window Manager -- Shows the brightness level of the laptop display -- More details could be found here: --- https://github.com/streetturtle/awesome-wm-widgets/tree/master/brightnessarc-widget +-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/widget-widget -- @author Pavel Makhov -- @copyright 2019 Pavel Makhov @@ -17,38 +17,56 @@ local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get" local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5" local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 5" -local icon = { - id = "icon", - image = PATH_TO_ICON, - resize = true, - widget = wibox.widget.imagebox, -} +local widget = {} -local brightnessarc = wibox.widget { - icon, - max_value = 1, - thickness = 2, - start_angle = 4.71238898, -- 2pi*3/4 - forced_height = 18, - forced_width = 18, - bg = "#ffffff11", - paddings = 2, - widget = wibox.container.arcchart -} +local function worker(args) -local update_widget = function(widget, stdout) - local brightness_level = string.match(stdout, "(%d?%d?%d?)") - brightness_level = tonumber(string.format("% 3d", brightness_level)) + local args = args or {} - widget.value = brightness_level / 100; -end, + local get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD + local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD + local dec_brightness_cmd = args.dec_brightness_cmd or DEC_BRIGHTNESS_CMD + local path_to_icon = args.path_to_icon or PATH_TO_ICON -brightnessarc:connect_signal("button::press", function(_, _, _, button) - if (button == 4) then spawn(INC_BRIGHTNESS_CMD, false) - elseif (button == 5) then spawn(DEC_BRIGHTNESS_CMD, false) - end -end) + local icon = { + id = "icon", + image = path_to_icon, + resize = true, + widget = wibox.widget.imagebox, + } -watch(GET_BRIGHTNESS_CMD, 1, update_widget, brightnessarc) + widget = wibox.widget { + icon, + max_value = 1, + thickness = 2, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = 18, + forced_width = 18, + bg = "#ffffff11", + paddings = 2, + widget = wibox.container.arcchart + } -return brightnessarc + local update_widget = function(widget, stdout) + local brightness_level = string.match(stdout, "(%d?%d?%d?)") + brightness_level = tonumber(string.format("% 3d", brightness_level)) + + widget.value = brightness_level / 100; + end, + + widget:connect_signal("button::press", function(_, _, _, button) + if (button == 4) then + spawn(inc_brightness_cmd, false) + elseif (button == 5) then + spawn(dec_brightness_cmd, false) + end + end) + + watch(get_brightness_cmd, 1, update_widget, widget) + + return widget +end + +return setmetatable(widget, { __call = function(_, ...) + return worker(...) +end }) From 51999cc3cbc27d65fc0e11ef07e5f9d41f1470a5 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Fri, 3 May 2019 20:00:07 -0400 Subject: [PATCH 13/31] update brightnessarc --- brightnessarc-widget/README.md | 4 +++- brightnessarc-widget/brightnessarc.lua | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/brightnessarc-widget/README.md b/brightnessarc-widget/README.md index d122d3a..e63f0dd 100644 --- a/brightnessarc-widget/README.md +++ b/brightnessarc-widget/README.md @@ -11,6 +11,7 @@ It is possible to customize widget by providing a table with all or some of the | `get_brightness_cmd` | `light -G` | Get current screen brightness | | `inc_brightness_cmd` | `light -A 5` | Increase brightness | | `dec_brightness_cmd` | `light -U 5`| Decrease brightness | +| `color` | `beautiful.fg_color` | Color of the arc | | `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon | ### Example: @@ -20,6 +21,7 @@ brightnessarc_widget({ get_brightness_cmd = 'xbacklight -get', inc_brightness_cmd = 'xbacklight -inc 5', dec_brightness_cmd = 'xbacklight -dec 5' + color = '/usr/share/icons/Arc/status/symbolic/brightness-display-symbolic.svg' }) ``` @@ -60,7 +62,7 @@ git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/aweso Require widget at the beginning of **rc.lua**: ```lua -local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness") +local brightnessarc_widget = require("awesome-wm-widgets.brightnessarc-widget.brightnessarc") ``` Add widget to the tasklist: diff --git a/brightnessarc-widget/brightnessarc.lua b/brightnessarc-widget/brightnessarc.lua index dac08e4..3c4641e 100644 --- a/brightnessarc-widget/brightnessarc.lua +++ b/brightnessarc-widget/brightnessarc.lua @@ -11,6 +11,7 @@ local wibox = require("wibox") local watch = require("awful.widget.watch") local spawn = require("awful.spawn") +local beautiful = require("beautiful") local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg" local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get" @@ -26,6 +27,7 @@ local function worker(args) local get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD local dec_brightness_cmd = args.dec_brightness_cmd or DEC_BRIGHTNESS_CMD + local color = args.color or beautiful.fg_color local path_to_icon = args.path_to_icon or PATH_TO_ICON local icon = { @@ -44,6 +46,7 @@ local function worker(args) forced_width = 18, bg = "#ffffff11", paddings = 2, + colors = {color}, widget = wibox.container.arcchart } From 57ae9fef44ea8f5070109033fc5c9377e584f9a9 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Fri, 3 May 2019 20:28:50 -0400 Subject: [PATCH 14/31] spotify config --- spotify-widget/README.md | 48 +++++++++++-- spotify-widget/spo-wid-custom.png | Bin 0 -> 4608 bytes spotify-widget/spo-wid-default.png | Bin 0 -> 3778 bytes spotify-widget/spotify.lua | 112 ++++++++++++++++------------- 4 files changed, 107 insertions(+), 53 deletions(-) create mode 100644 spotify-widget/spo-wid-custom.png create mode 100644 spotify-widget/spo-wid-default.png diff --git a/spotify-widget/README.md b/spotify-widget/README.md index eff3027..083963f 100644 --- a/spotify-widget/README.md +++ b/spotify-widget/README.md @@ -1,9 +1,9 @@ # Spotify widget -This widget displays currently playing song on [Spotify for Linux](https://www.spotify.com/download/linux/) client: ![screenshot](./spo-wid-1.png) and consists of two parts: +This widget displays currently playing song on [Spotify for Linux](https://www.spotify.com/download/linux/) client: ![screenshot](./spo-wid-default.png) and consists of two parts: - status icon which shows if music is currently playing - - artist and name of the current song playing + - artist and name of the current song ## Controls @@ -15,11 +15,42 @@ This widget displays currently playing song on [Spotify for Linux](https://www.s Note that widget uses the Arc icon theme, so it should be [installed](https://github.com/horst3180/arc-icon-theme#installation) first under **/usr/share/icons/Arc/** folder. +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `play_icon` | `/usr/share/icons/Arc/actions/24/player_play.png` | Play icon | +| `pause_icon` | `/usr/share/icons/Arc/actions/24/player_pause.png` | Pause icon | +| `font` | `Play 9`| Font | + +### Example: + +```lua +spotify_widget({ + font = 'Ubuntu Mono 9', + play_icon = '/usr/share/icons/Papirus-Light/24x24/categories/spotify.svg', + pause_icon = '/usr/share/icons/Papirus-Dark/24x24/panel/spotify-indicator.svg' +}) +``` + +Gives following widget: + +![screenshot](./spo-wid-custom.png) + ## Installation -First you need to have spotify CLI installed. Here is how you can do it (except widget part): [pavelmakhov.com/2016/02/awesome-wm-spotify](http://pavelmakhov.com/2016/02/awesome-wm-spotify) +First you need to have spotify CLI installed, it uses dbus to communicate with spotify-client: -To use this widget clone repo under **~/.config/awesome/** and then add it in **rc.lua**: +```bash +git clone https://gist.github.com/fa6258f3ff7b17747ee3.git +cd ./fa6258f3ff7b17747ee3 +chmod +x sp +sudo cp ./sp /usr/local/bin/ +``` + +Then clone repo under **~/.config/awesome/** and add widget in **rc.lua**: ```lua local spotify_widget = require("awesome-wm-widgets.spotify-widget.spotify") @@ -28,6 +59,13 @@ s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, ... - spotify_widget, + -- default + spotify_widget(), + -- customized + spotify_widget({ + font = 'Ubuntu Mono 9', + play_icon = '/usr/share/icons/Papirus-Light/24x24/categories/spotify.svg', + pause_icon = '/usr/share/icons/Papirus-Dark/24x24/panel/spotify-indicator.svg' + }), ... ``` diff --git a/spotify-widget/spo-wid-custom.png b/spotify-widget/spo-wid-custom.png new file mode 100644 index 0000000000000000000000000000000000000000..979ad3151822da722a42e5bffd91951a1cec5abd GIT binary patch literal 4608 zcmai2^;^^5`+hOHnTVuxGY}cl0!~Idx)H}|HK;}zoi_m~b^>Fh^ zA<2;Y!Su{&XlQ1ajh09*r$5}<-wfsIAL!)k0zC0XdAUgYA$?t3y#3rz{`=$|>Hq+K ztEY9(JP5msb@$idnMqS` zR!MO&h3oqPx@#Of-)c@p>tz!}-P|bX0k`B2+}^&yv15!9ZGtC#M3o0@@ABlJBdM(P zhlbB?NB!{G+wBlHPk9Xi!)UVpecl$An(D(H8M?vK#9rQXb*AG5m;p`U54w;+IZxXM z10~_6cZw5qi7Ga1?^*;Ep`QlB7as9(2=juGgLsCaBL>3OiAu&O z-1&;F>o}E7_>rr3W3A*IE9G@Jekf(J6kW81C^~cakZi{!!`6Hcs!;iG9gV59bzuWr~n)wny^y;~@mRxV~*- z%(`_2;-`<&#dn*7H<<@x{Lm^0G`L_``2EUDP|%>R&5h@Sp}Mdlb=iz{ormsS2{`2} zZ9j8=TYX*Z8?lNY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5PQY@qe86et{4&==GQlzBcUtXAbkvVki{K0|Lupj^!}M+7`R2 zYWs(h>^B3Le~A)>LU}-tWkr_5Z2ZC{cu342438BGh6i6iO7K7DJ&>q6oDZ3WX9y ssKrnylqft<807*qoM6N<$g8y(ag8%>k literal 0 HcmV?d00001 diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua index c6f2188..e826de9 100644 --- a/spotify-widget/spotify.lua +++ b/spotify-widget/spotify.lua @@ -14,59 +14,75 @@ local watch = require("awful.widget.watch") local GET_SPOTIFY_STATUS_CMD = 'sp status' local GET_CURRENT_SONG_CMD = 'sp current-oneline' -local PATH_TO_ICONS = "/usr/share/icons/Arc" -local spotify_widget = wibox.widget { - { - id = "icon", - widget = wibox.widget.imagebox, - }, - { - id = 'current_song', - widget = wibox.widget.textbox, - font = 'Play 9' - }, - layout = wibox.layout.align.horizontal, - set_status = function(self, is_playing) - self.icon.image = PATH_TO_ICONS .. - (is_playing and "/actions/24/player_play.png" - or "/actions/24/player_pause.png") - end, - set_text = function(self, path) - self.current_song.markup = path - end, -} +local spotify_widget = {} -local update_widget_icon = function(widget, stdout, _, _, _) - stdout = string.gsub(stdout, "\n", "") - widget:set_status(stdout == 'Playing' and true or false) -end +local function worker(args) -local update_widget_text = function(widget, stdout, _, _, _) - if string.find(stdout, 'Error: Spotify is not running.') ~= nil then - widget:set_text('') - widget:set_visible(false) - else - widget:set_text(stdout) - widget:set_visible(true) + local args = args or {} + + local play_icon = args.play_icon or '/usr/share/icons/Arc/actions/24/player_play.png' + local pause_icon = args.pause_icon or '/usr/share/icons/Arc/actions/24/player_pause.png' + local font = args.font or 'Play 9' + + spotify_widget = wibox.widget { + { + id = "icon", + widget = wibox.widget.imagebox, + }, + { + id = 'current_song', + widget = wibox.widget.textbox, + font = font + }, + layout = wibox.layout.align.horizontal, + set_status = function(self, is_playing) + self.icon.image = (is_playing and play_icon or pause_icon) + end, + set_text = function(self, path) + self.current_song.markup = path + end, + } + + local update_widget_icon = function(widget, stdout, _, _, _) + stdout = string.gsub(stdout, "\n", "") + widget:set_status(stdout == 'Playing' and true or false) end -end -watch(GET_SPOTIFY_STATUS_CMD, 1, update_widget_icon, spotify_widget) -watch(GET_CURRENT_SONG_CMD, 1, update_widget_text, spotify_widget) - ---- Adds mouse controls to the widget: --- - left click - play/pause --- - scroll up - play next song --- - scroll down - play previous song -spotify_widget:connect_signal("button::press", function(_, _, _, button) - if (button == 1) then awful.spawn("sp play", false) -- left click - elseif (button == 4) then awful.spawn("sp next", false) -- scroll up - elseif (button == 5) then awful.spawn("sp prev", false) -- scroll down + local update_widget_text = function(widget, stdout, _, _, _) + if string.find(stdout, 'Error: Spotify is not running.') ~= nil then + widget:set_text('') + widget:set_visible(false) + else + widget:set_text(stdout) + widget:set_visible(true) + end end - awful.spawn.easy_async(GET_SPOTIFY_STATUS_CMD, function(stdout, stderr, exitreason, exitcode) - update_widget_icon(spotify_widget, stdout, stderr, exitreason, exitcode) + + watch(GET_SPOTIFY_STATUS_CMD, 1, update_widget_icon, spotify_widget) + watch(GET_CURRENT_SONG_CMD, 1, update_widget_text, spotify_widget) + + --- Adds mouse controls to the widget: + -- - left click - play/pause + -- - scroll up - play next song + -- - scroll down - play previous song + spotify_widget:connect_signal("button::press", function(_, _, _, button) + if (button == 1) then + awful.spawn("sp play", false) -- left click + elseif (button == 4) then + awful.spawn("sp next", false) -- scroll up + elseif (button == 5) then + awful.spawn("sp prev", false) -- scroll down + end + awful.spawn.easy_async(GET_SPOTIFY_STATUS_CMD, function(stdout, stderr, exitreason, exitcode) + update_widget_icon(spotify_widget, stdout, stderr, exitreason, exitcode) + end) end) -end) -return spotify_widget + return spotify_widget + +end + +return setmetatable(spotify_widget, { __call = function(_, ...) + return worker(...) +end }) \ No newline at end of file From 7df447fb50947f52758ce2f8a1168099551da36b Mon Sep 17 00:00:00 2001 From: streetturtle Date: Fri, 3 May 2019 21:46:49 -0400 Subject: [PATCH 15/31] externalize config for weather widget --- weather-widget/weather.lua | 247 ++++++++++++++++++++----------------- 1 file changed, 131 insertions(+), 116 deletions(-) diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index d5f07f8..d060fd2 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -16,126 +16,141 @@ local secrets = require("awesome-wm-widgets.secrets") local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" -local icon_widget = wibox.widget { - { - id = "icon", - resize = false, - widget = wibox.widget.imagebox, - }, - layout = wibox.container.margin(_ , 0, 0, 3), - set_image = function(self, path) - self.icon.image = path - end, -} +local weather_widget = {} -local temp_widget = wibox.widget{ - font = "Play 9", - widget = wibox.widget.textbox, -} +local function worker(args) -local weather_widget = wibox.widget { - icon_widget, - temp_widget, - layout = wibox.layout.fixed.horizontal, -} + local args = args or {} ---- Maps openWeatherMap icons to Arc icons -local icon_map = { - ["01d"] = "weather-clear-symbolic.svg", - ["02d"] = "weather-few-clouds-symbolic.svg", - ["03d"] = "weather-clouds-symbolic.svg", - ["04d"] = "weather-overcast-symbolic.svg", - ["09d"] = "weather-showers-scattered-symbolic.svg", - ["10d"] = "weather-showers-symbolic.svg", - ["11d"] = "weather-storm-symbolic.svg", - ["13d"] = "weather-snow-symbolic.svg", - ["50d"] = "weather-fog-symbolic.svg", - ["01n"] = "weather-clear-night-symbolic.svg", - ["02n"] = "weather-few-clouds-night-symbolic.svg", - ["03n"] = "weather-clouds-night-symbolic.svg", - ["04n"] = "weather-overcast-symbolic.svg", - ["09n"] = "weather-showers-scattered-symbolic.svg", - ["10n"] = "weather-showers-symbolic.svg", - ["11n"] = "weather-storm-symbolic.svg", - ["13n"] = "weather-snow-symbolic.svg", - ["50n"] = "weather-fog-symbolic.svg" -} + local font = args.font or 'Play 9' + local city = args.city or 'Montreal,ca' + local api_key = args.api_key or naughty.notify{preset = naughty.config.presets.critical, text = 'OpenweatherMap API key is not set'} + local units = args.units or 'metric' ---- Return wind direction as a string. -local function to_direction(degrees) - -- Ref: https://www.campbellsci.eu/blog/convert-wind-directions - if degrees == nil then - return "Unknown dir" - end - local directions = { - "N", - "NNE", - "NE", - "ENE", - "E", - "ESE", - "SE", - "SSE", - "S", - "SSW", - "SW", - "WSW", - "W", - "WNW", - "NW", - "NNW", - "N", + local icon_widget = wibox.widget { + { + id = "icon", + resize = false, + widget = wibox.widget.imagebox, + }, + layout = wibox.container.margin(_, 0, 0, 3), + set_image = function(self, path) + self.icon.image = path + end, } - return directions[math.floor((degrees % 360) / 22.5) + 1] + + local temp_widget = wibox.widget { + font = font, + widget = wibox.widget.textbox, + } + + weather_widget = wibox.widget { + icon_widget, + temp_widget, + layout = wibox.layout.fixed.horizontal, + } + + --- Maps openWeatherMap icons to Arc icons + local icon_map = { + ["01d"] = "weather-clear-symbolic.svg", + ["02d"] = "weather-few-clouds-symbolic.svg", + ["03d"] = "weather-clouds-symbolic.svg", + ["04d"] = "weather-overcast-symbolic.svg", + ["09d"] = "weather-showers-scattered-symbolic.svg", + ["10d"] = "weather-showers-symbolic.svg", + ["11d"] = "weather-storm-symbolic.svg", + ["13d"] = "weather-snow-symbolic.svg", + ["50d"] = "weather-fog-symbolic.svg", + ["01n"] = "weather-clear-night-symbolic.svg", + ["02n"] = "weather-few-clouds-night-symbolic.svg", + ["03n"] = "weather-clouds-night-symbolic.svg", + ["04n"] = "weather-overcast-symbolic.svg", + ["09n"] = "weather-showers-scattered-symbolic.svg", + ["10n"] = "weather-showers-symbolic.svg", + ["11n"] = "weather-storm-symbolic.svg", + ["13n"] = "weather-snow-symbolic.svg", + ["50n"] = "weather-fog-symbolic.svg" + } + + --- Return wind direction as a string. + local function to_direction(degrees) + -- Ref: https://www.campbellsci.eu/blog/convert-wind-directions + if degrees == nil then + return "Unknown dir" + end + local directions = { + "N", + "NNE", + "NE", + "ENE", + "E", + "ESE", + "SE", + "SSE", + "S", + "SSW", + "SW", + "WSW", + "W", + "WNW", + "NW", + "NNW", + "N", + } + return directions[math.floor((degrees % 360) / 22.5) + 1] + end + + local weather_timer = gears.timer({ timeout = 60 }) + local resp + + weather_timer:connect_signal("timeout", function() + local resp_json, status = http.request('https://api.openweathermap.org/data/2.5/weather?q=' + .. city + .. '&appid=' .. api_key + .. '&units=' .. units) + if (status ~= 200 and resp_json ~= nil) then + local err_resp = json.decode(resp_json) + naughty.notify { + title = 'Weather Widget Error', + text = err_resp.message, + preset = naughty.config.presets.critical, + } + elseif (resp_json ~= nil) then + resp = json.decode(resp_json) + icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] + temp_widget:set_text(string.gsub(resp.main.temp, "%.%d+", "") + .. '°' + .. (units == 'metric' and 'C' or 'F')) + end + end) + weather_timer:start() + weather_timer:emit_signal("timeout") + + --- Notification with weather information. Popups when mouse hovers over the icon + local notification + weather_widget:connect_signal("mouse::enter", function() + notification = naughty.notify { + icon = path_to_icons .. icon_map[resp.weather[1].icon], + icon_size = 20, + text = '' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')
' .. + 'Humidity: ' .. resp.main.humidity .. '%
' .. + 'Temperature: ' .. resp.main.temp .. '°' + .. (secrets.weather_widget_units == 'metric' and 'C' or 'F') .. '
' .. + 'Pressure: ' .. resp.main.pressure .. 'hPa
' .. + 'Clouds: ' .. resp.clouds.all .. '%
' .. + 'Wind: ' .. resp.wind.speed .. 'm/s (' .. to_direction(resp.wind.deg) .. ')', + timeout = 5, hover_timeout = 10, + width = 200 + } + end) + + weather_widget:connect_signal("mouse::leave", function() + naughty.destroy(notification) + end) + + return weather_widget end -local weather_timer = gears.timer({ timeout = 60 }) -local resp - -weather_timer:connect_signal("timeout", function () - local resp_json, status = http.request('https://api.openweathermap.org/data/2.5/weather?q=' - .. secrets.weather_widget_city - .. '&appid=' .. secrets.weather_widget_api_key - .. '&units=' .. secrets.weather_widget_units) - if (status ~= 200 and resp_json ~= nil) then - local err_resp = json.decode(resp_json) - naughty.notify{ - title = 'Weather Widget Error', - text = err_resp.message, - preset = naughty.config.presets.critical, - } - elseif (resp_json ~= nil) then - resp = json.decode(resp_json) - icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] - temp_widget:set_text(string.gsub(resp.main.temp, "%.%d+", "") - .. '°' - .. (secrets.weather_widget_units == 'metric' and 'C' or 'F')) - end -end) -weather_timer:start() -weather_timer:emit_signal("timeout") - ---- Notification with weather information. Popups when mouse hovers over the icon -local notification -weather_widget:connect_signal("mouse::enter", function() - notification = naughty.notify{ - icon = path_to_icons .. icon_map[resp.weather[1].icon], - icon_size=20, - text = - '' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')
' .. - 'Humidity: ' .. resp.main.humidity .. '%
' .. - 'Temperature: ' .. resp.main.temp .. '°' - .. (secrets.weather_widget_units == 'metric' and 'C' or 'F') .. '
' .. - 'Pressure: ' .. resp.main.pressure .. 'hPa
' .. - 'Clouds: ' .. resp.clouds.all .. '%
' .. - 'Wind: ' .. resp.wind.speed .. 'm/s (' .. to_direction(resp.wind.deg) .. ')', - timeout = 5, hover_timeout = 10, - width = 200 - } -end) - -weather_widget:connect_signal("mouse::leave", function() - naughty.destroy(notification) -end) - -return weather_widget +return setmetatable(weather_widget, { __call = function(_, ...) + return worker(...) +end }) From cb394af13ab349ea3c99f6c8c6be208b276cc3a8 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 4 May 2019 21:03:13 -0400 Subject: [PATCH 16/31] update readme of weather widget --- weather-widget/README.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/weather-widget/README.md b/weather-widget/README.md index ef7282f..a7e67e5 100644 --- a/weather-widget/README.md +++ b/weather-widget/README.md @@ -4,6 +4,28 @@ Note that widget uses the Arc icon theme, so it should be [installed](https://github.com/horst3180/arc-icon-theme#installation) first under **/usr/share/icons/Arc/** folder. +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `font` | `Play 9` | Font | +| `city` | `Montreal,ca` | City name and country code, [more info](https://openweathermap.org/current) | +| `api_key` | none| API key, required | +| `units` | `metric` | `metric` for celsius, `imperial` for fahrenheit | + +### Example: + +```lua +weather_widget({ + api_key = 'your-api-key', + units = 'imperial', + font = 'Ubuntu Mono 9' +}), +``` + + ## Installation 1. Install lua socket - to make HTTP calls to get the weather information. @@ -24,7 +46,7 @@ Note that widget uses the Arc icon theme, so it should be [installed](https://gi git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/ ``` -1. Get Open Weather Map app id here: [openweathermap.org/appid](https://openweathermap.org/appid) and place it in **~/.config/awesome/awesome-wm-widgets/secrets.lua**, or directly in the widget. Don't forget to set also your city and units - C/F. +1. Get Open Weather Map app id here: [openweathermap.org/appid](https://openweathermap.org/appid). 1. Require weather widget at the beginning of **rc.lua**: @@ -39,7 +61,14 @@ Note that widget uses the Arc icon theme, so it should be [installed](https://gi { -- Right widgets layout = wibox.layout.fixed.horizontal, ... - weather_widget, + --default + weather_widget({api_key = 'your-api-key'}), + --customized + weather_widget({ + api_key = 'your-api-key', + units = 'imperial', + font = 'Ubuntu Mono 9' + }) ... ``` From 0b48f0b200143881a47bc5f5efefd2671e9baf63 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 1 Jun 2019 22:55:13 -0400 Subject: [PATCH 17/31] externalize config of batteryarc widget --- batteryarc-widget/README.md | 34 ++-- batteryarc-widget/batteryarc.lua | 307 +++++++++++++++++-------------- batteryarc-widget/warning.png | Bin 0 -> 13496 bytes 3 files changed, 189 insertions(+), 152 deletions(-) create mode 100644 batteryarc-widget/warning.png diff --git a/batteryarc-widget/README.md b/batteryarc-widget/README.md index cb73e09..d282b68 100644 --- a/batteryarc-widget/README.md +++ b/batteryarc-widget/README.md @@ -11,18 +11,27 @@ Depending of the battery status it could look following ways: - ![80_d](./80_d.png) - more than 40 percent - ![80_c](./80_c.png) - more than 40 percent, charging -Widget uses following beautiful variables with values: +If a battery level is low then warning popup will show up: -```lua -theme.widget_main_color = "#74aeab" -theme.widget_red = "#e53935" -theme.widget_yellow = "#c0ca33" -theme.widget_green = "#43a047" -theme.widget_black = "#000000" -theme.widget_transparent = "#00000000" -``` +![warning](./warning.png) + +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `font` | Font | Play 6 | +| `arc_thickness` | Thickness of the arc | 2 | +| `text_color` | Color of text with the current charge | `beautiful.fg_color` | +| `low_level_color` | Arc color when battery charge is less that 15%| #e53935 | +| `medium_level_color` | Arc color when battery charge is between 15% and 40% | #c0ca33 | +| `full_level_color` | Arc color when battery charge is above 40% | `beautiful.fg_color` | +| `warning_msg_title` | Title of the warning popup | _Huston, we have a problem_ | +| `warning_msg_text` | Text of the warning popup | _Battery is dying_ | +| `warning_msg_position` | Position of the warning popup | `bottom_right` | +| `warning_msg_icon` | Icon of the warning popup| ~/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg | -which means that you need to copy the code above and paste it in your **theme.lua**. Otherwise you can change colors directly in the widget. ## Installation @@ -35,11 +44,10 @@ s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, ... - batteryarc_widget, + batteryarc_widget(), ... ``` -You can get the icon for warning popup [here](https://vk.com/images/stickers/1933/512.png) ## Troubleshooting -In case of any doubts or questions don't hesitate to raise an [issue](https://github.com/streetturtle/awesome-wm-widgets/issues/new). +In case of any doubts or questions please raise an [issue](https://github.com/streetturtle/awesome-wm-widgets/issues/new). diff --git a/batteryarc-widget/batteryarc.lua b/batteryarc-widget/batteryarc.lua index a15151f..cf10b81 100644 --- a/batteryarc-widget/batteryarc.lua +++ b/batteryarc-widget/batteryarc.lua @@ -16,151 +16,180 @@ local watch = require("awful.widget.watch") local HOME = os.getenv("HOME") -local text = wibox.widget { - id = "txt", - font = "Play 6", - align = 'center', -- align the text - valign = 'center', - widget = wibox.widget.textbox -} +local widget = {} -local text_with_background = wibox.container.background(text) +local function worker(args) -local batteryarc = wibox.widget { - text_with_background, - max_value = 1, - rounded_edge = true, - thickness = 2, - start_angle = 4.71238898, -- 2pi*3/4 - forced_height = 18, - forced_width = 18, - bg = "#ffffff11", - paddings = 2, - widget = wibox.container.arcchart, - set_value = function(self, value) - self.value = value - end, -} + local args = args or {} -local last_battery_check = os.time() + local font = args.font or 'Play 6' + local arc_thickness = args.thickness or 2 -watch("acpi -i", 10, - function(widget, stdout) - local batteryType + local text_color = args.text_color or beautiful.fg_color + local low_level_color = args.low_level_color or '#e53935' + local medium_level_color = args.medium_level_color or '#c0ca33' + local full_level_color = args.full_level_color or beautiful.fg_color - local battery_info = {} - local capacities = {} - for s in stdout:gmatch("[^\r\n]+") do - local status, charge_str, time = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?.*') - if string.match(s, 'rate information') then - -- ignore such line - elseif status ~= nil then - table.insert(battery_info, {status = status, charge = tonumber(charge_str)}) - else - local cap_str = string.match(s, '.+:.+last full capacity (%d+)') - table.insert(capacities, tonumber(cap_str)) - end - end + local warning_msg_title = args.warning_msg_title or 'Huston, we have a problem' + local warning_msg_text = args.warning_msg_text or 'Battery is dying' + local warning_msg_position = args.warning_msg_position or 'bottom_right' + local warning_msg_icon = args.warning_msg_icon or HOME .. '/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg' - local capacity = 0 - for i, cap in ipairs(capacities) do - capacity = capacity + cap - end - - local charge = 0 - local status - for i, batt in ipairs(battery_info) do - if batt.charge >= charge then - -- use most charged battery status. This is arbitrary, and maybe another metric should be used - status = batt.status - end - - charge = charge + batt.charge * capacities[i] - end - - local charge_percentage - if capacity > 5 then - charge = charge / capacity - charge_percentage = charge / 100 - else - -- when widget.value is < 0.04, the widget shows a full circle (as widget.value=1) - charge_percentage = 0.05 - end - - widget.value = charge / 100 - - if status == 'Charging' then - text_with_background.bg = beautiful.widget_green - text_with_background.fg = beautiful.widget_black - else - text_with_background.bg = beautiful.widget_transparent - text_with_background.fg = beautiful.widget_main_color - end - - --- if battery is fully charged (100) there is not enough place for three digits, so we don't show any text - text.text = charge == 100 - and '' - or string.format('%d', charge) - - if charge < 15 then - batteryarc.colors = { beautiful.widget_red } - if status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then - -- if 5 minutes have elapsed since the last warning - last_battery_check = os.time() - - show_battery_warning() - end - elseif charge > 15 and charge < 40 then - batteryarc.colors = { beautiful.widget_yellow } - else - batteryarc.colors = { beautiful.widget_main_color } - end - end, - batteryarc) - --- Popup with battery info --- One way of creating a pop-up notification - naughty.notify -local notification -function show_battery_status() - awful.spawn.easy_async([[bash -c 'acpi']], - function(stdout, _, _, _) - naughty.destroy(notification) - notification = naughty.notify { - text = stdout, - title = "Battery status", - timeout = 5, - hover_timeout = 0.5, - width = 200, - } - end) -end - -batteryarc:connect_signal("mouse::enter", function() show_battery_status() end) -batteryarc:connect_signal("mouse::leave", function() naughty.destroy(notification) end) - --- Alternative to naughty.notify - tooltip. You can compare both and choose the preferred one - ---battery_popup = awful.tooltip({objects = {battery_widget}}) - --- To use colors from beautiful theme put --- following lines in rc.lua before require("battery"): --- beautiful.tooltip_fg = beautiful.fg_normal --- beautiful.tooltip_bg = beautiful.bg_normal - ---[[ Show warning notification ]] -function show_battery_warning() - naughty.notify { - icon = HOME .. "/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg", - icon_size = 100, - text = "Battery is dying", -- switch text and title - title = "Huston, we have a problem", - timeout = 25, -- show the warning for a longer time - hover_timeout = 0.5, - position = "bottom_right", - bg = "#F06060", - fg = "#EEE9EF", - width = 300, + local text = wibox.widget { + id = "txt", + font = font, + align = 'center', -- align the text + valign = 'center', + widget = wibox.widget.textbox } + + local text_with_background = wibox.container.background(text) + + widget = wibox.widget { + text_with_background, + max_value = 1, + rounded_edge = true, + thickness = arc_thickness, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = 18, + forced_width = 18, + bg = "#ffffff11", + paddings = 2, + widget = wibox.container.arcchart, + set_value = function(self, value) + self.value = value + end, + } + + local last_battery_check = os.time() + + watch("acpi -i", 10, + function(widget, stdout) + local batteryType + + local battery_info = {} + local capacities = {} + for s in stdout:gmatch("[^\r\n]+") do + local status, charge_str, time = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?.*') + if string.match(s, 'rate information') then + -- ignore such line + elseif status ~= nil then + table.insert(battery_info, { status = status, charge = tonumber(charge_str) }) + else + local cap_str = string.match(s, '.+:.+last full capacity (%d+)') + table.insert(capacities, tonumber(cap_str)) + end + end + + local capacity = 0 + for i, cap in ipairs(capacities) do + capacity = capacity + cap + end + + local charge = 0 + local status + for i, batt in ipairs(battery_info) do + if batt.charge >= charge then + -- use most charged battery status. This is arbitrary, and maybe another metric should be used + status = batt.status + end + + charge = charge + batt.charge * capacities[i] + end + + local charge_percentage + if capacity > 5 then + charge = charge / capacity + charge_percentage = charge / 100 + else + -- when widget.value is < 0.04, the widget shows a full circle (as widget.value=1) + charge_percentage = 0.05 + end + + widget.value = charge / 100 + + if status == 'Charging' then + text_with_background.bg = full_level_color + text_with_background.fg = '#000000' + else + text_with_background.bg = '#00000000' + text_with_background.fg = text_color + end + + --- if battery is fully charged (100) there is not enough place for three digits, so we don't show any text + text.text = charge == 100 + and '' + or string.format('%d', charge) + + if charge < 15 then + widget.colors = { low_level_color } + if status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then + -- if 5 minutes have elapsed since the last warning + last_battery_check = os.time() + + show_battery_warning() + end + elseif charge > 15 and charge < 40 then + widget.colors = { medium_level_color } + else + widget.colors = { full_level_color } + end + end, + widget) + + -- Popup with battery info + -- One way of creating a pop-up notification - naughty.notify + local notification + function show_battery_status() + awful.spawn.easy_async([[bash -c 'acpi']], + function(stdout, _, _, _) + naughty.destroy(notification) + notification = naughty.notify { + text = stdout, + title = "Battery status", + timeout = 5, + hover_timeout = 0.5, + width = 200, + } + end) + end + + widget:connect_signal("mouse::enter", function() + show_battery_status() + end) + widget:connect_signal("mouse::leave", function() + naughty.destroy(notification) + end) + + -- Alternative to naughty.notify - tooltip. You can compare both and choose the preferred one + + --battery_popup = awful.tooltip({objects = {battery_widget}}) + + -- To use colors from beautiful theme put + -- following lines in rc.lua before require("battery"): + -- beautiful.tooltip_fg = beautiful.fg_normal + -- beautiful.tooltip_bg = beautiful.bg_normal + + --[[ Show warning notification ]] + function show_battery_warning() + naughty.notify { + icon = warning_msg_icon, + icon_size = 100, + text = warning_msg_text, + title = warning_msg_title, + timeout = 25, -- show the warning for a longer time + hover_timeout = 0.5, + position = warning_msg_position, + bg = "#F06060", + fg = "#EEE9EF", + width = 300, + } + end + + return widget + end -return batteryarc +return setmetatable(widget, { __call = function(_, ...) + return worker(...) +end }) diff --git a/batteryarc-widget/warning.png b/batteryarc-widget/warning.png new file mode 100644 index 0000000000000000000000000000000000000000..55ca7902bcbcdce8c1229f2802281696550381b6 GIT binary patch literal 13496 zcmd6OWmp_d@aN*TgbnTvL4uRuF2Nmw2Djk41lPq9+zD=h;0}uu*x(ijusAOe+?|En z```22=lghHW~QfSrfRCIt4n?ztEKS)AD0pr007`CE6M8s04N5?>tt+H>BfBXnHHu);gnfnHNzRO4V^Hcl$|LqIp*7_b*6}Ht?H)mPR@+uY7zBWMS zzT+pS3~q^g{Qy5T&y21!)K?_o4HVdZi1k5hHQ~m?JZBuG>*oJy0*#uy_opq}g=qf$ zUs(v)aiT_yfAQF!Zj=8tKJJ`TzJ97%F=strFNE`2B*8kTJV2yGXLsR}?5m0hEp5bC zF;0v6Hc+zV*KS!FI(Zv-t0lP#d(E|>5NvS!$5$~NcMqtRx%s-G(0{_(D))hsWyG(C ztQs0z6QW_-6p4g=-UmAdsP!^ky7XIEd%LrRW zJ})oNdXt;Dzha4xr@96(81C=wvg7OOlL>t+4$5Qbq9Tm^4Tuc?CMRoHpa z`#mlsdtaa3M-r=4sEunlo!IdONPWQZLE4 z8qiZEuDEUOVV|?EONY|Nq}7pJMFf&`X*c2gqtY=;r`s1%-YbD{1~XccOV+%LA!uVo zYAq#^Ch7`(m$mR3H2;23Y>&v0AQ(3^_FYU%BiY-md&Fso&?jR|2bfN|V4C$_V>VXE zE!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qs754=!M3VQ%FaEeU%VdR_9TM ziR5|mu}M!?mr&Qg2=j+4jM$2h>(zi|@9M?R6Wf&fv)l(o>qggG z@5~WvQf5MrZRLY;==;NJwcBErJqx?1|b0^;OC90R->Rb+slgyu5JyR;c>$MZtREwTB~Jlz3(qQ zy;`rXa-aYHS=;MrX3wr%n%gt?NBHbjy*pl#Hj^(V&|3ZZ+;y=FmwZ}!p?SWn>NW~- zY`;uThYqo;e)6-Nm@TvR=|^rr`Hrl&pAA8!ZYHM0w|XQXVETI%d(*R8&UHE>=~kEH zf}WS3E+T3e8}7$LZKj4adfj6A-IwvbD`|FX_Zwh3w)-=w-~%aF^o>%eZ?%Tgzn*z; z@aBip`)RTD>wQ&3J#=9O>T-SJT?fb3#1I$PkVKN-tY`8b-6!h~LwypEyc^`1y1(oV zys67`oPJx>BntG>5) Date: Sun, 2 Jun 2019 09:46:41 -0400 Subject: [PATCH 18/31] improve batteryarc config --- batteryarc-widget/README.md | 16 ++++++++++++---- batteryarc-widget/batteryarc.lua | 23 ++++++++++++++--------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/batteryarc-widget/README.md b/batteryarc-widget/README.md index d282b68..4f35097 100644 --- a/batteryarc-widget/README.md +++ b/batteryarc-widget/README.md @@ -23,10 +23,11 @@ It is possible to customize widget by providing a table with all or some of the |---|---|---| | `font` | Font | Play 6 | | `arc_thickness` | Thickness of the arc | 2 | -| `text_color` | Color of text with the current charge | `beautiful.fg_color` | +| `show_current_level`| Show current charge level | false | +| `main_color` | Color of the text with the current charge level and the arc| `beautiful.fg_color` | | `low_level_color` | Arc color when battery charge is less that 15%| #e53935 | | `medium_level_color` | Arc color when battery charge is between 15% and 40% | #c0ca33 | -| `full_level_color` | Arc color when battery charge is above 40% | `beautiful.fg_color` | +| `charging` | Color of the circle inside the arc when charging | `beautiful.fg_color` | | `warning_msg_title` | Title of the warning popup | _Huston, we have a problem_ | | `warning_msg_text` | Text of the warning popup | _Battery is dying_ | | `warning_msg_position` | Position of the warning popup | `bottom_right` | @@ -44,8 +45,15 @@ s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, ... - batteryarc_widget(), - ... + --[[default]] + batteryarc_widget(), + --[[or customized]] + batteryarc_widget({ + show_current_level = true, + thickness = '1', + }), + } + ... ``` ## Troubleshooting diff --git a/batteryarc-widget/batteryarc.lua b/batteryarc-widget/batteryarc.lua index cf10b81..7a7109f 100644 --- a/batteryarc-widget/batteryarc.lua +++ b/batteryarc-widget/batteryarc.lua @@ -24,11 +24,12 @@ local function worker(args) local font = args.font or 'Play 6' local arc_thickness = args.thickness or 2 + local show_current_level = args.show_current_level or false - local text_color = args.text_color or beautiful.fg_color + local main_color = args.main_color or beautiful.fg_color local low_level_color = args.low_level_color or '#e53935' local medium_level_color = args.medium_level_color or '#c0ca33' - local full_level_color = args.full_level_color or beautiful.fg_color + local charging_color = args.charging_color or '#43a047' local warning_msg_title = args.warning_msg_title or 'Huston, we have a problem' local warning_msg_text = args.warning_msg_text or 'Battery is dying' @@ -109,17 +110,21 @@ local function worker(args) widget.value = charge / 100 if status == 'Charging' then - text_with_background.bg = full_level_color + text_with_background.bg = charging_color text_with_background.fg = '#000000' else text_with_background.bg = '#00000000' - text_with_background.fg = text_color + text_with_background.fg = main_color end - --- if battery is fully charged (100) there is not enough place for three digits, so we don't show any text - text.text = charge == 100 - and '' - or string.format('%d', charge) + if show_current_level == true then + --- if battery is fully charged (100) there is not enough place for three digits, so we don't show any text + text.text = charge == 100 + and '' + or string.format('%d', charge) + else + text.text = '' + end if charge < 15 then widget.colors = { low_level_color } @@ -132,7 +137,7 @@ local function worker(args) elseif charge > 15 and charge < 40 then widget.colors = { medium_level_color } else - widget.colors = { full_level_color } + widget.colors = { main_color } end end, widget) From fb465d371ec9ec93262ec6991c633ffdcd545daf Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sun, 2 Jun 2019 22:05:06 -0400 Subject: [PATCH 19/31] fix table in readme of batteryarc --- batteryarc-widget/README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/batteryarc-widget/README.md b/batteryarc-widget/README.md index 4f35097..026180e 100644 --- a/batteryarc-widget/README.md +++ b/batteryarc-widget/README.md @@ -22,17 +22,16 @@ It is possible to customize widget by providing a table with all or some of the | Name | Default | Description | |---|---|---| | `font` | Font | Play 6 | -| `arc_thickness` | Thickness of the arc | 2 | -| `show_current_level`| Show current charge level | false | -| `main_color` | Color of the text with the current charge level and the arc| `beautiful.fg_color` | -| `low_level_color` | Arc color when battery charge is less that 15%| #e53935 | -| `medium_level_color` | Arc color when battery charge is between 15% and 40% | #c0ca33 | -| `charging` | Color of the circle inside the arc when charging | `beautiful.fg_color` | -| `warning_msg_title` | Title of the warning popup | _Huston, we have a problem_ | -| `warning_msg_text` | Text of the warning popup | _Battery is dying_ | -| `warning_msg_position` | Position of the warning popup | `bottom_right` | -| `warning_msg_icon` | Icon of the warning popup| ~/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg | - +| `arc_thickness` | 2 | Thickness of the arc | +| `show_current_level`| false | Show current charge level | +| `main_color` | `beautiful.fg_color` | Color of the text with the current charge level and the arc | +| `low_level_color` | #e53935 | Arc color when battery charge is less that 15% | +| `medium_level_color` | #c0ca33 | Arc color when battery charge is between 15% and 40% | +| `charging` | `beautiful.fg_color` | Color of the circle inside the arc when charging | +| `warning_msg_title` | _Huston, we have a problem_ | Title of the warning popup | +| `warning_msg_text` | _Battery is dying_ | Text of the warning popup | +| `warning_msg_position` | `bottom_right` | Position of the warning popup | +| `warning_msg_icon` | ~/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg | Icon of the warning popup | ## Installation From 712d11568afe8b9da82920f9e8b08f12c4029736 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sun, 2 Jun 2019 22:05:37 -0400 Subject: [PATCH 20/31] externalize config for cpu widget --- cpu-widget/README.md | 40 ++++++++++++++++++--- cpu-widget/cpu-widget.lua | 74 ++++++++++++++++++++++++--------------- 2 files changed, 82 insertions(+), 32 deletions(-) diff --git a/cpu-widget/README.md b/cpu-widget/README.md index 500e1b9..31fb0d6 100644 --- a/cpu-widget/README.md +++ b/cpu-widget/README.md @@ -2,9 +2,7 @@ This widget shows the average CPU load among all cores of the machine: -![screenshot](out.gif) - -When the load is more than 80% the graph becomes red. You can easily customize the widget by changing colors, step width, step spacing, width and interval. +![screenshot](cpu.gif) ## How it works @@ -18,6 +16,32 @@ cpu 197294 718 50102 2002182 3844 0 2724 0 0 0 and calculates the percentage. +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `width` | 50 | Width of the widget | +| `step_width` | 2 | Width of the step | +| `step_spacing` | 1 | Space size between steps | +| `color` | `beautiful.fg_normal` | Color of the graph | + +### Example + +```lua +cpu_widget({ + width = 70, + step_width = 2, + step_spacing = 0, + color = '#434c5e' +}) +``` + +The config above results in the following widget: + +![custom](./custom.png) + ## Installation Clone/download repo and use widget in **rc.lua**: @@ -29,6 +53,14 @@ s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, ... - cpu_widget, + -- default + cpu_widget(), + -- or custom + cpu_widget({ + width = 70, + step_width = 2, + step_spacing = 0, + color = '#434c5e' + }) ... ``` diff --git a/cpu-widget/cpu-widget.lua b/cpu-widget/cpu-widget.lua index 88ebea9..0e027dd 100644 --- a/cpu-widget/cpu-widget.lua +++ b/cpu-widget/cpu-widget.lua @@ -10,40 +10,58 @@ local watch = require("awful.widget.watch") local wibox = require("wibox") +local beautiful = require("beautiful") -local cpugraph_widget = wibox.widget { - max_value = 100, - background_color = "#00000000", - forced_width = 50, - step_width = 2, - step_spacing = 1, - widget = wibox.widget.graph, - color = "linear:0,0:0,22:0,#FF0000:0.3,#FFFF00:0.5,#74aeab" -} +local widget = {} ---- By default graph widget goes from left to right, so we mirror it and push up a bit -local cpu_widget = wibox.container.margin(wibox.container.mirror(cpugraph_widget, { horizontal = true }), 0, 0, 0, 2) +local function worker(args) -local total_prev = 0 -local idle_prev = 0 + local args = args or {} -watch([[bash -c "cat /proc/stat | grep '^cpu '"]], 1, - function(widget, stdout) - local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice = - stdout:match('(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s') + local width = args.width or 50 + local step_width = args.step_width or 2 + local step_spacing = args.step_spacing or 1 + local color= args.color or beautiful.fg_normal - local total = user + nice + system + idle + iowait + irq + softirq + steal + local cpugraph_widget = wibox.widget { + max_value = 100, + background_color = "#00000000", + forced_width = width, + step_width = step_width, + step_spacing = step_spacing, + widget = wibox.widget.graph, + color = "linear:0,0:0,20:0,#FF0000:0.3,#FFFF00:0.6," .. color + } - local diff_idle = idle - idle_prev - local diff_total = total - total_prev - local diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10 + --- By default graph widget goes from left to right, so we mirror it and push up a bit + local cpu_widget = wibox.container.margin(wibox.container.mirror(cpugraph_widget, { horizontal = true }), 0, 0, 0, 2) - widget:add_value(diff_usage) + local total_prev = 0 + local idle_prev = 0 - total_prev = total - idle_prev = idle - end, - cpugraph_widget -) + watch([[bash -c "cat /proc/stat | grep '^cpu '"]], 1, + function(widget, stdout) + local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice = + stdout:match('(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s') -return cpu_widget + local total = user + nice + system + idle + iowait + irq + softirq + steal + + local diff_idle = idle - idle_prev + local diff_total = total - total_prev + local diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10 + + widget:add_value(diff_usage) + + total_prev = total + idle_prev = idle + end, + cpugraph_widget + ) + + return cpu_widget + +end + +return setmetatable(widget, { __call = function(_, ...) + return worker(...) +end }) From d331fd2f0d0d74c4f7bb62ca0efae0babed2e5ae Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sun, 2 Jun 2019 22:06:02 -0400 Subject: [PATCH 21/31] fix grammar in readme of volumearc --- volumearc-widget/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index aac7e90..9f59fc1 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -36,7 +36,7 @@ volumearc_widget({ }) ``` -Above config results in following widget: +The config above results in the following widget: ![custom](./custom.png) From 74f7e583de5d16c0a32af1e148e7df5ad6887dbd Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sun, 2 Jun 2019 22:06:25 -0400 Subject: [PATCH 22/31] add screenshots of cpu widget --- cpu-widget/cpu.gif | Bin 0 -> 4913 bytes cpu-widget/custom.png | Bin 0 -> 1922 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 cpu-widget/cpu.gif create mode 100644 cpu-widget/custom.png diff --git a/cpu-widget/cpu.gif b/cpu-widget/cpu.gif new file mode 100644 index 0000000000000000000000000000000000000000..086e618def202be4162a984e67937cd3427fbc65 GIT binary patch literal 4913 zcmds42~<;O7JiV09ob|PF>Df9G=@E3NC<%t5JDgrHccQXL`9=$i&_Q(vM)i1sDMq_ ziRc6eEOD#{*^FB2Qn6O4LscAXoeo;={7x3dfwYD|@+4Alf#kJ8A^3F^JdxrR9O@lRg;-z<3r7j} zCQ-epbgwY5B7GvFeIsN1z>13Tr_cgIBM6~%0+k*}jU>|62S-HvMKS!=#}d{v17hO| zv8=#YRuD5GD1Ji_i%m>OBqk&g6H|f{Q{iWWr?VguJ%${~2#JcNF%u%=6QegIM{h_0 zHyDYju}K@rshp6FTnaZmG%bV5+Z?_nid-vx-kPL!U5K9KJR4howf>bP)jKxyHm*G#~Cb$6Z!`IYX zWROe+sbr8!l~_=aBorncJeXQsoLW+{sj8AClkpDK^6C!p>gzJ<>v-aNep4gAxsiXo zDZ5pg-3C_6j*ixyo$Wij+67%5f^M)n1+vav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3+S$FiMjBU9=_WhJI3J?46zvq>*iRjMnBw)GE+fX{rH z%2cMF=L;cxpS}OVr8{@00U!`!VewunWfn>$$8`}xl*-|hIu55l9ql~Y-#z@~#79@` zF}L;fexsj;T}Fq2w)s1+eI0#aqme986kSzx-*-LF!5CvK=~~>-lN(1q%v&PXl1ya6 zcGW6Xs>^{0f`EtiZOBwZ*Ciq`pVe%8V{ce1003Rnh)g)+kE|6u^OGMYJK7%93J%N0 zAf;Ie0Hkz#*H`fj4gCv`0zkELRUY3KoCy(NEFpw6EuM(AAcTD8DO6JxJsd-+8jqy_z;$b(9V0AL6#-(*3&&uLB~0M{ z5`V!WVImU>2!sgMw(C4E=UkR$Ns=TiZCY+c2!%q11t78Zc(WPHQ#1RX97wcg&9>a) ztvk+~XN~&hD{lFU+qAso0ppx;&Uvu1X;Y$5`q(b-p??VzY5n<52q8p(5MDh@20;*r zl~u+FV=RT1u)WbU<33|Pkz_*TMlzd7lBR263VNQ;7z+RrSeK8uV&YOS+0`p z-go>5-<7EB)$FOO*YlrERF{^85KYr^chKN2jWO0#RU(_$0U~_o6;HQ(^Tp@P&i1v& zrtPu2gN<*BO%X!)zRx)a0SH#^mq8FP#$3mBJ@1iQ>lg5Bd-B?i;!GX^B2-2ahV9SG zJ-#}2 Date: Thu, 11 Jul 2019 13:31:46 -0400 Subject: [PATCH 23/31] pr #84 --- secrets.lua | 8 ++++---- weather-widget/weather.lua | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/secrets.lua b/secrets.lua index 9e3dace..e110fe5 100644 --- a/secrets.lua +++ b/secrets.lua @@ -7,12 +7,12 @@ local secrets = { -- Yandex.Translate API key - https://tech.yandex.com/translate/ - translate_widget_api_key = 'API_KEY', + translate_widget_api_key = os.getenv('AWW_TRANSLATE_API_KEY') or 'API_KEY', -- OpenWeatherMap API key - https://openweathermap.org/appid - weather_widget_api_key = 'API_KEY', - weather_widget_city = 'Montreal,ca', - weather_widget_units = 'metric' -- for celsius, or 'imperial' for fahrenheit + weather_widget_api_key = os.getenv('AWW_WEATHER_API_KEY') or 'c3d7320b359da4e48c2d682a04076576', + weather_widget_city = os.getenv('AWW_WEATHER_CITY') or 'Montreal,ca', + weather_widget_units = os.getenv('AWW_WEATHER_UNITS') or 'metric' -- for celsius, or 'imperial' for fahrenheit } return secrets diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index d060fd2..deeff61 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -7,6 +7,8 @@ ------------------------------------------------- local http = require("socket.http") +local socket = require("socket") +local ltn12 = require("ltn12") local json = require("json") local naughty = require("naughty") local wibox = require("wibox") @@ -27,6 +29,13 @@ local function worker(args) local api_key = args.api_key or naughty.notify{preset = naughty.config.presets.critical, text = 'OpenweatherMap API key is not set'} local units = args.units or 'metric' + local weather_api_url = ( + 'https://api.openweathermap.org/data/2.5/weather' + .. '?q=' .. city + .. '&appid=' .. api_key + .. '&units=' .. units + ) + local icon_widget = wibox.widget { { id = "icon", @@ -104,10 +113,26 @@ local function worker(args) local resp weather_timer:connect_signal("timeout", function() - local resp_json, status = http.request('https://api.openweathermap.org/data/2.5/weather?q=' - .. city - .. '&appid=' .. api_key - .. '&units=' .. units) + local resp_json = {} + local res, status = http.request{ + url=weather_api_url, + sink=ltn12.sink.table(resp_json), + -- ref: + -- http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0/http.html + create=function() + -- ref: https://stackoverflow.com/a/6021774/595220 + local req_sock = socket.tcp() + -- 't' — overall timeout + req_sock:settimeout(0.2, 't') + -- 'b' — block timeout + req_sock:settimeout(0.001, 'b') + return req_sock + end + } + if (resp_json ~= nil) then + resp_json = table.concat(resp_json) + end + if (status ~= 200 and resp_json ~= nil) then local err_resp = json.decode(resp_json) naughty.notify { @@ -115,7 +140,7 @@ local function worker(args) text = err_resp.message, preset = naughty.config.presets.critical, } - elseif (resp_json ~= nil) then + elseif (resp_json ~= nil and resp_json ~= '') then resp = json.decode(resp_json) icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] temp_widget:set_text(string.gsub(resp.main.temp, "%.%d+", "") From 54500cf15d1272ee63edd44de695c6e803f570ce Mon Sep 17 00:00:00 2001 From: streetturtle Date: Mon, 2 Sep 2019 15:37:45 -0400 Subject: [PATCH 24/31] externalize config for ram-widget --- ram-widget/ram-widget.lua | 148 ++++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 68 deletions(-) diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua index 3072068..a5414c8 100644 --- a/ram-widget/ram-widget.lua +++ b/ram-widget/ram-widget.lua @@ -2,77 +2,89 @@ local awful = require("awful") local watch = require("awful.widget.watch") local wibox = require("wibox") ---- Main ram widget shown on wibar -local ramgraph_widget = wibox.widget { - border_width = 0, - colors = { - '#74aeab', '#26403f' - }, - display_labels = false, - forced_width = 25, - widget = wibox.widget.piechart -} +local ramgraph_widget = {} ---- Widget which is shown when user clicks on the ram widget -local w = wibox { - height = 200, - width = 400, - ontop = true, - expand = true, - bg = '#1e252c', - max_widget_size = 500 -} +local function worker(args) -w:setup { - border_width = 0, - colors = { - '#5ea19d', - '#55918e', - '#4b817e', - }, - display_labels = false, - forced_width = 25, - id = 'pie', - widget = wibox.widget.piechart -} + local args = args or {} -local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap + --- Main ram widget shown on wibar + ramgraph_widget = wibox.widget { + border_width = 0, + colors = { + '#74aeab', '#26403f' + }, + display_labels = false, + forced_width = 25, + widget = wibox.widget.piechart + } -local function getPercentage(value) - return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%' + --- Widget which is shown when user clicks on the ram widget + local w = wibox { + height = 200, + width = 400, + ontop = true, + expand = true, + bg = '#1e252c', + max_widget_size = 500 + } + + w:setup { + border_width = 0, + colors = { + '#5ea19d', + '#55918e', + '#4b817e', + }, + display_labels = false, + forced_width = 25, + id = 'pie', + widget = wibox.widget.piechart + } + + local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap + + local function getPercentage(value) + return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%' + end + + watch('bash -c "free | grep -z Mem.*Swap.*"', 1, + function(widget, stdout, stderr, exitreason, exitcode) + total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap = + stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)') + + widget.data = { used, total-used } widget.data = { used, total-used } + + if w.visible then + w.pie.data_list = { + {'used ' .. getPercentage(used + used_swap), used + used_swap}, + {'free ' .. getPercentage(free + free_swap), free + free_swap}, + {'buff_cache ' .. getPercentage(buff_cache), buff_cache} + } + end + end, + ramgraph_widget + ) + + ramgraph_widget:buttons( + awful.util.table.join( + awful.button({}, 1, function() + awful.placement.top_right(w, { margins = {top = 25, right = 10}, parent = awful.screen.focused() }) + w.pie.data_list = { + {'used ' .. getPercentage(used + used_swap), used + used_swap}, + {'free ' .. getPercentage(free + free_swap), free + free_swap}, + {'buff_cache ' .. getPercentage(buff_cache), buff_cache} + } + w.pie.display_labels = true + w.visible = not w.visible + end) + ) + ) + + + return ramgraph_widget end -watch('bash -c "free | grep -z Mem.*Swap.*"', 1, - function(widget, stdout, stderr, exitreason, exitcode) - total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap = - stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)') - - widget.data = { used, total-used } widget.data = { used, total-used } - - if w.visible then - w.pie.data_list = { - {'used ' .. getPercentage(used + used_swap), used + used_swap}, - {'free ' .. getPercentage(free + free_swap), free + free_swap}, - {'buff_cache ' .. getPercentage(buff_cache), buff_cache} - } - end - end, - ramgraph_widget -) - -ramgraph_widget:buttons( - awful.util.table.join( - awful.button({}, 1, function() - awful.placement.top_right(w, { margins = {top = 25, right = 10}, parent = awful.screen.focused() }) - w.pie.data_list = { - {'used ' .. getPercentage(used + used_swap), used + used_swap}, - {'free ' .. getPercentage(free + free_swap), free + free_swap}, - {'buff_cache ' .. getPercentage(buff_cache), buff_cache} - } - w.pie.display_labels = true - w.visible = not w.visible - end) - ) -) - -return ramgraph_widget +return setmetatable(ramgraph_widget, { __call = function(_, ...) + return worker(...) +end }) From b41daeb9b2fd0206124740b165bcb8254a84c7b4 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 3 Jun 2019 16:35:40 +0200 Subject: [PATCH 25/31] Query weather with async timeouts Fixes #81 --- weather-widget/weather.lua | 80 +++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index deeff61..0899b8f 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -6,8 +6,8 @@ -- @copyright 2018 Pavel Makhov ------------------------------------------------- -local http = require("socket.http") local socket = require("socket") +local http = require("socket.http") local ltn12 = require("ltn12") local json = require("json") local naughty = require("naughty") @@ -109,47 +109,47 @@ local function worker(args) return directions[math.floor((degrees % 360) / 22.5) + 1] end - local weather_timer = gears.timer({ timeout = 60 }) - local resp +local weather_timer = gears.timer({ timeout = 60 }) +local resp - weather_timer:connect_signal("timeout", function() - local resp_json = {} - local res, status = http.request{ - url=weather_api_url, - sink=ltn12.sink.table(resp_json), - -- ref: - -- http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0/http.html - create=function() - -- ref: https://stackoverflow.com/a/6021774/595220 - local req_sock = socket.tcp() - -- 't' — overall timeout - req_sock:settimeout(0.2, 't') - -- 'b' — block timeout - req_sock:settimeout(0.001, 'b') - return req_sock - end +weather_timer:connect_signal("timeout", function () + local resp_json = {} + local res, status = http.request{ + url=weather_api_url, + sink=ltn12.sink.table(resp_json), + -- ref: + -- http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0/http.html + create=function() + -- ref: https://stackoverflow.com/a/6021774/595220 + local req_sock = socket.tcp() + -- 't' — overall timeout + req_sock:settimeout(0.2, 't') + -- 'b' — block timeout + req_sock:settimeout(0.001, 'b') + return req_sock + end + } + if (resp_json ~= nil) then + resp_json = table.concat(resp_json) + end + + if (status ~= 200 and resp_json ~= nil and resp_json ~= '') then + local err_resp = json.decode(resp_json) + naughty.notify{ + title = 'Weather Widget Error', + text = err_resp.message, + preset = naughty.config.presets.critical, } - if (resp_json ~= nil) then - resp_json = table.concat(resp_json) - end - - if (status ~= 200 and resp_json ~= nil) then - local err_resp = json.decode(resp_json) - naughty.notify { - title = 'Weather Widget Error', - text = err_resp.message, - preset = naughty.config.presets.critical, - } - elseif (resp_json ~= nil and resp_json ~= '') then - resp = json.decode(resp_json) - icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] - temp_widget:set_text(string.gsub(resp.main.temp, "%.%d+", "") - .. '°' - .. (units == 'metric' and 'C' or 'F')) - end - end) - weather_timer:start() - weather_timer:emit_signal("timeout") + elseif (resp_json ~= nil and resp_json ~= '') then + resp = json.decode(resp_json) + icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] + temp_widget:set_text(string.gsub(resp.main.temp, "%.%d+", "") + .. '°' + .. (secrets.weather_widget_units == 'metric' and 'C' or 'F')) + end +end) +weather_timer:start() +weather_timer:emit_signal("timeout") --- Notification with weather information. Popups when mouse hovers over the icon local notification From 2752c06548c419ba657adb67e7a94a1dc5d5d1fa Mon Sep 17 00:00:00 2001 From: Marcel von Maltitz Date: Fri, 19 Jul 2019 18:46:28 +0200 Subject: [PATCH 26/31] Make ram-widget compatible for non-english OS The output of the free command is grep'ed while assuming english column names. This grep fails when given non-english localization. Setting the LANGUAGE variable inside the bash invocation solves this problem. --- ram-widget/ram-widget.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua index a5414c8..d8cb11f 100644 --- a/ram-widget/ram-widget.lua +++ b/ram-widget/ram-widget.lua @@ -48,7 +48,7 @@ local function worker(args) return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%' end - watch('bash -c "free | grep -z Mem.*Swap.*"', 1, + watch('bash -c "LANGUAGE=en_US.UTF-8 free | grep -z Mem.*Swap.*"', 1, function(widget, stdout, stderr, exitreason, exitcode) total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap = stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)') From e1b866e23753e69ce27db64dc6b6b261e6022e24 Mon Sep 17 00:00:00 2001 From: ticktronaut Date: Thu, 1 Aug 2019 10:35:16 +0200 Subject: [PATCH 27/31] Fixed buggy spawning of os.time(). --- battery-widget/battery.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua index 6d9f086..aa3623d 100644 --- a/battery-widget/battery.lua +++ b/battery-widget/battery.lua @@ -109,7 +109,7 @@ watch("acpi -i", 10, batteryType = "battery-empty%s-symbolic" if status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then -- if 5 minutes have elapsed since the last warning - last_battery_check = time() + last_battery_check = os.time() show_battery_warning() end From 7997625cdc334a1e52ca46335399219753500875 Mon Sep 17 00:00:00 2001 From: blix4 Date: Mon, 26 Aug 2019 22:28:43 -0700 Subject: [PATCH 28/31] fix after applying blix4's commit --- secrets.lua | 13 +++- weather-widget/README.md | 2 + weather-widget/weather.lua | 125 +++++++++++++++++++++++-------------- 3 files changed, 91 insertions(+), 49 deletions(-) diff --git a/secrets.lua b/secrets.lua index e110fe5..381f04d 100644 --- a/secrets.lua +++ b/secrets.lua @@ -5,6 +5,15 @@ -- @copyright 2019 Pavel Makhov -------------------------------------------- +local function getenv_bool(var_name, default_val) + val = os.getenv(var_name) + if val ~= nil then + return val:lower() == 'true' + else + return default_val + end +end + local secrets = { -- Yandex.Translate API key - https://tech.yandex.com/translate/ translate_widget_api_key = os.getenv('AWW_TRANSLATE_API_KEY') or 'API_KEY', @@ -12,7 +21,9 @@ local secrets = { -- OpenWeatherMap API key - https://openweathermap.org/appid weather_widget_api_key = os.getenv('AWW_WEATHER_API_KEY') or 'c3d7320b359da4e48c2d682a04076576', weather_widget_city = os.getenv('AWW_WEATHER_CITY') or 'Montreal,ca', - weather_widget_units = os.getenv('AWW_WEATHER_UNITS') or 'metric' -- for celsius, or 'imperial' for fahrenheit + weather_widget_units = os.getenv('AWW_WEATHER_UNITS') or 'metric', -- for celsius, or 'imperial' for fahrenheit + weather_both_temp_units_widget = getenv_bool('AWW_WEATHER_BOTH_UNITS_WIDGET', false), -- on widget, if true shows "22 C (72 F)", instead of only "22 C" + weather_both_temp_units_popup = getenv_bool('AWW_WEATHER_BOTH_UNITS_POPUP', true) -- in the popup, if true shows "22.3 C (72.2 F)" instead of only "22.3 C" } return secrets diff --git a/weather-widget/README.md b/weather-widget/README.md index a7e67e5..6464fcc 100644 --- a/weather-widget/README.md +++ b/weather-widget/README.md @@ -14,6 +14,8 @@ It is possible to customize widget by providing a table with all or some of the | `city` | `Montreal,ca` | City name and country code, [more info](https://openweathermap.org/current) | | `api_key` | none| API key, required | | `units` | `metric` | `metric` for celsius, `imperial` for fahrenheit | +| `both_units_widget` | `false` | show temperature in both units (15°C (59°F)) or in one (15°C) | +| `both_units_popup` | `false` | same as above but for popup | ### Example: diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index 0899b8f..b0aa070 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -14,8 +14,6 @@ local naughty = require("naughty") local wibox = require("wibox") local gears = require("gears") -local secrets = require("awesome-wm-widgets.secrets") - local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" local weather_widget = {} @@ -28,6 +26,8 @@ local function worker(args) local city = args.city or 'Montreal,ca' local api_key = args.api_key or naughty.notify{preset = naughty.config.presets.critical, text = 'OpenweatherMap API key is not set'} local units = args.units or 'metric' + local both_units_widget = args.both_units_widget or false + local both_units_popup = args.both_units_popup or false local weather_api_url = ( 'https://api.openweathermap.org/data/2.5/weather' @@ -109,63 +109,92 @@ local function worker(args) return directions[math.floor((degrees % 360) / 22.5) + 1] end -local weather_timer = gears.timer({ timeout = 60 }) -local resp + -- Convert degrees Celsius to Fahrenheit + local function celsius_to_fahrenheit(c) + return c*9/5+32 + end -weather_timer:connect_signal("timeout", function () - local resp_json = {} - local res, status = http.request{ - url=weather_api_url, - sink=ltn12.sink.table(resp_json), - -- ref: - -- http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0/http.html - create=function() - -- ref: https://stackoverflow.com/a/6021774/595220 - local req_sock = socket.tcp() - -- 't' — overall timeout - req_sock:settimeout(0.2, 't') - -- 'b' — block timeout - req_sock:settimeout(0.001, 'b') - return req_sock + -- Convert degrees Fahrenheit to Celsius + local function fahrenheit_to_celsius(f) + return (f-32)*5/9 + end + + local weather_timer = gears.timer({ timeout = 60 }) + local resp + + local function gen_temperature_str(temp, fmt_str, show_other_units) + local temp_str = string.format(fmt_str, temp) + local s = temp_str .. '°' .. (units == 'metric' and 'C' or 'F') + + if (show_other_units) then + local temp_conv, units_conv + if (units == 'metric') then + temp_conv = celsius_to_fahrenheit(temp) + units_conv = 'F' + else + temp_conv = fahrenheit_to_celsius(temp) + units_conv = 'C' + end + + local temp_conv_str = string.format(fmt_str, temp_conv) + s = s .. ' ' .. '('.. temp_conv_str .. '°' .. units_conv .. ')' end - } - if (resp_json ~= nil) then - resp_json = table.concat(resp_json) + return s end - if (status ~= 200 and resp_json ~= nil and resp_json ~= '') then - local err_resp = json.decode(resp_json) - naughty.notify{ - title = 'Weather Widget Error', - text = err_resp.message, - preset = naughty.config.presets.critical, + weather_timer:connect_signal("timeout", function () + local resp_json = {} + local res, status = http.request{ + url=weather_api_url, + sink=ltn12.sink.table(resp_json), + -- ref: + -- http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0/http.html + create=function() + -- ref: https://stackoverflow.com/a/6021774/595220 + local req_sock = socket.tcp() + -- 't' — overall timeout + req_sock:settimeout(0.2, 't') + -- 'b' — block timeout + req_sock:settimeout(0.001, 'b') + return req_sock + end } - elseif (resp_json ~= nil and resp_json ~= '') then - resp = json.decode(resp_json) - icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] - temp_widget:set_text(string.gsub(resp.main.temp, "%.%d+", "") - .. '°' - .. (secrets.weather_widget_units == 'metric' and 'C' or 'F')) - end -end) -weather_timer:start() -weather_timer:emit_signal("timeout") + if (resp_json ~= nil) then + resp_json = table.concat(resp_json) + end + + if (status ~= 200 and resp_json ~= nil and resp_json ~= '') then + local err_resp = json.decode(resp_json) + naughty.notify{ + title = 'Weather Widget Error', + text = err_resp.message, + preset = naughty.config.presets.critical, + } + elseif (resp_json ~= nil and resp_json ~= '') then + resp = json.decode(resp_json) + icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] + temp_widget:set_text(gen_temperature_str(resp.main.temp, '%.0f', both_units_widget)) + end + end) + weather_timer:start() + weather_timer:emit_signal("timeout") --- Notification with weather information. Popups when mouse hovers over the icon local notification weather_widget:connect_signal("mouse::enter", function() - notification = naughty.notify { + notification = naughty.notify{ icon = path_to_icons .. icon_map[resp.weather[1].icon], - icon_size = 20, - text = '' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')
' .. - 'Humidity: ' .. resp.main.humidity .. '%
' .. - 'Temperature: ' .. resp.main.temp .. '°' - .. (secrets.weather_widget_units == 'metric' and 'C' or 'F') .. '
' .. - 'Pressure: ' .. resp.main.pressure .. 'hPa
' .. - 'Clouds: ' .. resp.clouds.all .. '%
' .. - 'Wind: ' .. resp.wind.speed .. 'm/s (' .. to_direction(resp.wind.deg) .. ')', + icon_size=20, + text = + '' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')
' .. + 'Humidity: ' .. resp.main.humidity .. '%
' .. + 'Temperature: ' .. gen_temperature_str(resp.main.temp, '%.1f', + both_units_popup) .. '
' .. + 'Pressure: ' .. resp.main.pressure .. 'hPa
' .. + 'Clouds: ' .. resp.clouds.all .. '%
' .. + 'Wind: ' .. resp.wind.speed .. 'm/s (' .. to_direction(resp.wind.deg) .. ')', timeout = 5, hover_timeout = 10, - width = 200 + width = (both_units_popup == true and 210 or 200) } end) From dbee6f75f727b68092890d814d24b84136363e75 Mon Sep 17 00:00:00 2001 From: blix4 Date: Tue, 27 Aug 2019 00:20:08 -0700 Subject: [PATCH 29/31] volume widget support amixer with no device specified This works on my setup without having pulseaudio installed. --- secrets.lua | 3 +++ volume-widget/README.md | 25 +++++++++++++++++++++++++ volume-widget/volume.lua | 19 ++++++++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/secrets.lua b/secrets.lua index 381f04d..5e3b988 100644 --- a/secrets.lua +++ b/secrets.lua @@ -15,6 +15,9 @@ local function getenv_bool(var_name, default_val) end local secrets = { + -- See volume-widget/README.md + volume_audio_controller = os.getenv('AWW_VOLUME_CONTROLLER') or 'pulse', -- 'pulse' or 'alsa_only' + -- Yandex.Translate API key - https://tech.yandex.com/translate/ translate_widget_api_key = os.getenv('AWW_TRANSLATE_API_KEY') or 'API_KEY', diff --git a/volume-widget/README.md b/volume-widget/README.md index 118abc6..494be24 100644 --- a/volume-widget/README.md +++ b/volume-widget/README.md @@ -31,6 +31,31 @@ s.mytasklist, -- Middle widget sudo sed -i 's/bebebe/ed4737/g' ./audio-volume-muted-symbolic_red.svg ``` +### Pulse or ALSA only + +Try running this command: + +```amixer -D pulse sget Master``` + +If that prints something like this, then the default setting of 'pulse' is probably fine: +``` +Simple mixer control 'Master',0 + Capabilities: pvolume pvolume-joined pswitch pswitch-joined + Playback channels: Mono + Limits: Playback 0 - 64 + Mono: Playback 64 [100%] [0.00dB] [on] + +``` + +If it prints something like this: +``` +$ amixer -D pulse sget Master +ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused + +amixer: Mixer attach pulse error: Connection refused +``` +then try setting the environment variable `AWW_VOLUME_CONTROLLER` to `alsa_only`. + ## Control volume To mute/unmute click on the widget. To increase/decrease volume scroll up or down when mouse cursor is over the widget. diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 8124bcf..04f1c26 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -13,12 +13,21 @@ local wibox = require("wibox") local watch = require("awful.widget.watch") local spawn = require("awful.spawn") +local secrets = require("awesome-wm-widgets.secrets") + local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" -local GET_VOLUME_CMD = 'amixer -D pulse sget Master' -local INC_VOLUME_CMD = 'amixer -D pulse sset Master 5%+' -local DEC_VOLUME_CMD = 'amixer -D pulse sset Master 5%-' -local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' +if secrets.volume_audio_controller == 'pulse' then + device_arg = '-D pulse' +else + device_arg = '' +end + +local GET_VOLUME_CMD = 'amixer ' .. device_arg .. ' sget Master' +local INC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%+' +local DEC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%-' +local TOG_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master toggle' + local volume_widget = wibox.widget { { @@ -64,4 +73,4 @@ end) watch(GET_VOLUME_CMD, 1, update_graphic, volume_widget) -return volume_widget \ No newline at end of file +return volume_widget From 0999de2bfd2e9f7ccd5d0e04eb1f63c3803449ae Mon Sep 17 00:00:00 2001 From: streetturtle Date: Tue, 3 Sep 2019 21:57:24 -0400 Subject: [PATCH 30/31] externalize config of volume widget --- volume-widget/README.md | 30 +++++++++-- volume-widget/volume.lua | 108 ++++++++++++++++++++----------------- volumearc-widget/README.md | 2 +- 3 files changed, 84 insertions(+), 56 deletions(-) diff --git a/volume-widget/README.md b/volume-widget/README.md index 494be24..24c2d76 100644 --- a/volume-widget/README.md +++ b/volume-widget/README.md @@ -1,10 +1,18 @@ # Volume widget -Simple and easy-to-install widget for Awesome Window Manager which represents the sound level: ![Volume Widget]( +Simple and easy-to-install widget for Awesome Window Manager which shows the sound level: ![Volume Widget]( ./vol-widget-1.png) Note that widget uses the Arc icon theme, so it should be [installed](https://github.com/horst3180/arc-icon-theme#installation) first under **/usr/share/icons/Arc/** folder. +## Customization + +It is possible to customize widget by providing a table with all or some of the following config parameters: + +| Name | Default | Description | +|---|---|---| +| `volume_audio_controller` | `pulse` | audio device | + ## Installation - clone/copy **volume.lua** file; @@ -18,7 +26,7 @@ s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, ... - volume_widget, + volume_widget(), ... ``` @@ -35,9 +43,12 @@ s.mytasklist, -- Middle widget Try running this command: -```amixer -D pulse sget Master``` +```bash +amixer -D pulse sget Master +``` If that prints something like this, then the default setting of 'pulse' is probably fine: + ``` Simple mixer control 'Master',0 Capabilities: pvolume pvolume-joined pswitch pswitch-joined @@ -48,13 +59,22 @@ Simple mixer control 'Master',0 ``` If it prints something like this: -``` + +```bash $ amixer -D pulse sget Master ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused amixer: Mixer attach pulse error: Connection refused ``` -then try setting the environment variable `AWW_VOLUME_CONTROLLER` to `alsa_only`. +then set `volume_audio_controller` to `alsa_only` in widget constructor: + +```lua +volume_widget({ + volume_audio_controller = 'alsa_only' +}) +``` + +. ## Control volume diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 04f1c26..6172f5e 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -13,64 +13,72 @@ local wibox = require("wibox") local watch = require("awful.widget.watch") local spawn = require("awful.spawn") -local secrets = require("awesome-wm-widgets.secrets") - local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" -if secrets.volume_audio_controller == 'pulse' then - device_arg = '-D pulse' -else - device_arg = '' -end +local volume_widget = {} -local GET_VOLUME_CMD = 'amixer ' .. device_arg .. ' sget Master' -local INC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%+' -local DEC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%-' -local TOG_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master toggle' +local function worker(args) + local args = args or {} -local volume_widget = wibox.widget { - { - id = "icon", - image = path_to_icons .. "audio-volume-muted-symbolic.svg", - resize = false, - widget = wibox.widget.imagebox, - }, - layout = wibox.container.margin(_, _, _, 3), - set_image = function(self, path) - self.icon.image = path - end -} + local volume_audio_controller = args.volume_audio_controller or 'pulse' -local update_graphic = function(widget, stdout, _, _, _) - local mute = string.match(stdout, "%[(o%D%D?)%]") - local volume = string.match(stdout, "(%d?%d?%d)%%") - volume = tonumber(string.format("% 3d", volume)) - local volume_icon_name - if mute == "off" then volume_icon_name="audio-volume-muted-symbolic_red" - elseif (volume >= 0 and volume < 25) then volume_icon_name="audio-volume-muted-symbolic" - elseif (volume < 50) then volume_icon_name="audio-volume-low-symbolic" - elseif (volume < 75) then volume_icon_name="audio-volume-medium-symbolic" - elseif (volume <= 100) then volume_icon_name="audio-volume-high-symbolic" - end - widget.image = path_to_icons .. volume_icon_name .. ".svg" -end - ---[[ allows control volume level by: -- clicking on the widget to mute/unmute -- scrolling when cursor is over the widget -]] -volume_widget:connect_signal("button::press", function(_,_,_,button) - if (button == 4) then awful.spawn(INC_VOLUME_CMD, false) - elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD, false) - elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD, false) + local device_arg = '' + if volume_audio_controller == 'pulse' then + device_arg = '-D pulse' end - spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) - update_graphic(volume_widget, stdout, stderr, exitreason, exitcode) + local GET_VOLUME_CMD = 'amixer ' .. device_arg .. ' sget Master' + local INC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%+' + local DEC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%-' + local TOG_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master toggle' + + + volume_widget = wibox.widget { + { + id = "icon", + image = path_to_icons .. "audio-volume-muted-symbolic.svg", + resize = false, + widget = wibox.widget.imagebox, + }, + layout = wibox.container.margin(_, _, _, 3), + set_image = function(self, path) + self.icon.image = path + end + } + + local update_graphic = function(widget, stdout, _, _, _) + local mute = string.match(stdout, "%[(o%D%D?)%]") + local volume = string.match(stdout, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + local volume_icon_name + if mute == "off" then volume_icon_name="audio-volume-muted-symbolic_red" + elseif (volume >= 0 and volume < 25) then volume_icon_name="audio-volume-muted-symbolic" + elseif (volume < 50) then volume_icon_name="audio-volume-low-symbolic" + elseif (volume < 75) then volume_icon_name="audio-volume-medium-symbolic" + elseif (volume <= 100) then volume_icon_name="audio-volume-high-symbolic" + end + widget.image = path_to_icons .. volume_icon_name .. ".svg" + end + + --[[ allows control volume level by: + - clicking on the widget to mute/unmute + - scrolling when cursor is over the widget + ]] + volume_widget:connect_signal("button::press", function(_,_,_,button) + if (button == 4) then awful.spawn(INC_VOLUME_CMD, false) + elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD, false) + elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD, false) + end + + spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode) + update_graphic(volume_widget, stdout, stderr, exitreason, exitcode) + end) end) -end) -watch(GET_VOLUME_CMD, 1, update_graphic, volume_widget) + watch(GET_VOLUME_CMD, 1, update_graphic, volume_widget) -return volume_widget + return volume_widget +end + +return setmetatable(volume_widget, { __call = function(_, ...) return worker(...) end }) diff --git a/volumearc-widget/README.md b/volumearc-widget/README.md index 9f1a60e..0ae17b4 100644 --- a/volumearc-widget/README.md +++ b/volumearc-widget/README.md @@ -1,6 +1,6 @@ # Volumearc widget -Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using arcchart: +Almost the same as [volumebar widget](https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget), but using [arcchart](https://awesomewm.org/doc/api/classes/wibox.container.arcchart.html): ![screenshot](out.gif) From bcd001e487d4d1a9c0ec5335b662d67496e10a4e Mon Sep 17 00:00:00 2001 From: streetturtle Date: Tue, 3 Sep 2019 22:01:51 -0400 Subject: [PATCH 31/31] delete secrets.lua --- secrets.lua | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 secrets.lua diff --git a/secrets.lua b/secrets.lua deleted file mode 100644 index 5e3b988..0000000 --- a/secrets.lua +++ /dev/null @@ -1,32 +0,0 @@ -------------------------------------------------- --- Allows to store client specific settings in one place --- --- @author Pavel Makhov --- @copyright 2019 Pavel Makhov --------------------------------------------- - -local function getenv_bool(var_name, default_val) - val = os.getenv(var_name) - if val ~= nil then - return val:lower() == 'true' - else - return default_val - end -end - -local secrets = { - -- See volume-widget/README.md - volume_audio_controller = os.getenv('AWW_VOLUME_CONTROLLER') or 'pulse', -- 'pulse' or 'alsa_only' - - -- Yandex.Translate API key - https://tech.yandex.com/translate/ - translate_widget_api_key = os.getenv('AWW_TRANSLATE_API_KEY') or 'API_KEY', - - -- OpenWeatherMap API key - https://openweathermap.org/appid - weather_widget_api_key = os.getenv('AWW_WEATHER_API_KEY') or 'c3d7320b359da4e48c2d682a04076576', - weather_widget_city = os.getenv('AWW_WEATHER_CITY') or 'Montreal,ca', - weather_widget_units = os.getenv('AWW_WEATHER_UNITS') or 'metric', -- for celsius, or 'imperial' for fahrenheit - weather_both_temp_units_widget = getenv_bool('AWW_WEATHER_BOTH_UNITS_WIDGET', false), -- on widget, if true shows "22 C (72 F)", instead of only "22 C" - weather_both_temp_units_popup = getenv_bool('AWW_WEATHER_BOTH_UNITS_POPUP', true) -- in the popup, if true shows "22.3 C (72.2 F)" instead of only "22.3 C" -} - -return secrets