From 052b345ebc008d4999fba240e57f450640d0b573 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Mon, 20 Feb 2017 13:15:53 +0300 Subject: [PATCH] Shorter records for icon+text buttons (Lua syntax used). --- rc.lua | 18 +++++++++--------- wi.lua | 8 +------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/rc.lua b/rc.lua index 66a4187..479d1fd 100644 --- a/rc.lua +++ b/rc.lua @@ -270,34 +270,34 @@ function show_nethogs () os.execute ("pgrep nethogs || urxvt -e sudo nethogs &") end icon_wifi:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wifi0") end), awful.button({ }, 3, show_nethogs))) -wifi_widget_down:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wifi0") end), awful.button({ }, 3, show_nethogs))) -icon_wifi_down_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wifi0") end), awful.button({ }, 3, show_nethogs))) -wifi_widget_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wifi0") end), awful.button({ }, 3, show_nethogs))) +wifi_widget_down:buttons(icon_wifi:buttons()) +icon_wifi_down_up:buttons(icon_wifi:buttons()) +wifi_widget_up:buttons(icon_wifi:buttons()) icon_wired:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wan0") end), awful.button({ }, 3, show_nethogs))) -wired_widget_down:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wan0") end), awful.button({ }, 3, show_nethogs))) -icon_wired_down_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wan0") end), awful.button({ }, 3, show_nethogs))) -wired_widget_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wan0") end), awful.button({ }, 3, show_nethogs))) +wired_widget_down:buttons(icon_wired:buttons()) +icon_wired_down_up:buttons(icon_wired:buttons()) +wired_widget_up:buttons(icon_wired:buttons()) -- CPU icon function show_htop () os.execute ("pgrep htop || urxvt -e htop &") end cpuicon:buttons(awful.util.table.join(awful.button({ }, 1, show_htop))) -cpu:buttons(awful.util.table.join(awful.button({ }, 1, show_htop))) +cpu:buttons(cpuicon:buttons()) -- Memory icon function show_atop () os.execute ("pgrep atop || urxvt -e atop &") end memicon:buttons(awful.util.table.join(awful.button({ }, 1, show_atop))) -mem:buttons(awful.util.table.join(awful.button({ }, 1, show_atop))) +mem:buttons(memicon:buttons()) -- Disk icon function show_iotop () os.execute ("pgrep iotop || urxvt -e sudo iotop --delay=4 &") end diskicon:buttons(awful.util.table.join(awful.button({ }, 1, show_iotop))) -disk:buttons(awful.util.table.join(awful.button({ }, 1, show_iotop))) +disk:buttons(diskicon:buttons()) vicious.cache(vicious.widgets.net) vicious.register(wifi_widget_down, vicious.widgets.net, '${wifi0 down_mb}', 2) diff --git a/wi.lua b/wi.lua index 3a98455..db7e57c 100644 --- a/wi.lua +++ b/wi.lua @@ -81,13 +81,7 @@ volicon:buttons( ) ) volpct = wibox.widget.textbox() -volpct:buttons( - awful.util.table.join( - awful.button({ }, 1, function () awful.util.spawn("urxvt -e alsamixer --view=all") end), - awful.button({ }, 4, function () os.execute("pgrep -x amixer || amixer set Master 1%+") end), - awful.button({ }, 5, function () os.execute("pgrep -x amixer || amixer set Master 1%-") end) - ) -) +volpct:buttons(volicon:buttons()) vicious.register(volpct, vicious.widgets.volume, "$1% ", nil, "Master") ----< CPU >-----------------------------------------------------------