Shorter records for icon+text buttons (Lua syntax used).

This commit is contained in:
Kolan Sh 2017-02-20 13:15:53 +03:00
parent b1b1d3567a
commit 052b345ebc
2 changed files with 10 additions and 16 deletions

18
rc.lua
View File

@ -270,34 +270,34 @@ function show_nethogs ()
os.execute ("pgrep nethogs || urxvt -e sudo nethogs &") os.execute ("pgrep nethogs || urxvt -e sudo nethogs &")
end end
icon_wifi:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wifi0") end), awful.button({ }, 3, show_nethogs))) 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))) wifi_widget_down:buttons(icon_wifi:buttons())
icon_wifi_down_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wifi0") end), awful.button({ }, 3, show_nethogs))) icon_wifi_down_up:buttons(icon_wifi:buttons())
wifi_widget_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wifi0") end), awful.button({ }, 3, show_nethogs))) 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))) 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))) wired_widget_down:buttons(icon_wired:buttons())
icon_wired_down_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wan0") end), awful.button({ }, 3, show_nethogs))) icon_wired_down_up:buttons(icon_wired:buttons())
wired_widget_up:buttons(awful.util.table.join(awful.button({ }, 1, function () show_nload("wan0") end), awful.button({ }, 3, show_nethogs))) wired_widget_up:buttons(icon_wired:buttons())
-- CPU icon -- CPU icon
function show_htop () function show_htop ()
os.execute ("pgrep htop || urxvt -e htop &") os.execute ("pgrep htop || urxvt -e htop &")
end end
cpuicon:buttons(awful.util.table.join(awful.button({ }, 1, show_htop))) 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 -- Memory icon
function show_atop () function show_atop ()
os.execute ("pgrep atop || urxvt -e atop &") os.execute ("pgrep atop || urxvt -e atop &")
end end
memicon:buttons(awful.util.table.join(awful.button({ }, 1, show_atop))) 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 -- Disk icon
function show_iotop () function show_iotop ()
os.execute ("pgrep iotop || urxvt -e sudo iotop --delay=4 &") os.execute ("pgrep iotop || urxvt -e sudo iotop --delay=4 &")
end end
diskicon:buttons(awful.util.table.join(awful.button({ }, 1, show_iotop))) 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.cache(vicious.widgets.net)
vicious.register(wifi_widget_down, vicious.widgets.net, '<span color="#baa53f">${wifi0 down_mb}</span>', 2) vicious.register(wifi_widget_down, vicious.widgets.net, '<span color="#baa53f">${wifi0 down_mb}</span>', 2)

8
wi.lua
View File

@ -81,13 +81,7 @@ volicon:buttons(
) )
) )
volpct = wibox.widget.textbox() volpct = wibox.widget.textbox()
volpct:buttons( volpct:buttons(volicon: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)
)
)
vicious.register(volpct, vicious.widgets.volume, "$1% ", nil, "Master") vicious.register(volpct, vicious.widgets.volume, "$1% ", nil, "Master")
----< CPU >----------------------------------------------------------- ----< CPU >-----------------------------------------------------------