From e5b1984f0e868a29fc2b171bb8d672d5e202f844 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 1 May 2017 16:10:07 -0300 Subject: Create a widgets folder --- .gitmodules | 4 +- config.dot/awesome.link/awesompd | 1 - config.dot/awesome.link/awesompd.lua | 57 ---------------------------- config.dot/awesome.link/leds.lua | 13 ------- config.dot/awesome.link/volume.lua | 34 ----------------- config.dot/awesome.link/widgets.lua | 6 +-- config.dot/awesome.link/widgets/awesompd | 1 + config.dot/awesome.link/widgets/awesompd.lua | 57 ++++++++++++++++++++++++++++ config.dot/awesome.link/widgets/leds.lua | 13 +++++++ config.dot/awesome.link/widgets/volume.lua | 34 +++++++++++++++++ 10 files changed, 110 insertions(+), 110 deletions(-) delete mode 160000 config.dot/awesome.link/awesompd delete mode 100644 config.dot/awesome.link/awesompd.lua delete mode 100644 config.dot/awesome.link/leds.lua delete mode 100644 config.dot/awesome.link/volume.lua create mode 160000 config.dot/awesome.link/widgets/awesompd create mode 100644 config.dot/awesome.link/widgets/awesompd.lua create mode 100644 config.dot/awesome.link/widgets/leds.lua create mode 100644 config.dot/awesome.link/widgets/volume.lua diff --git a/.gitmodules b/.gitmodules index 0f5d6bf..0b90d23 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ -[submodule "config.dot/awesome.link/awesompd"] - path = config.dot/awesome.link/awesompd +[submodule "config.dot/awesome.link/widgets/awesompd"] + path = config.dot/awesome.link/widgets/awesompd url = git://git.fluxo.info/awesompd.git [submodule "config.dot/awesome.link/powerarrow"] path = config.dot/awesome.link/powerarrow diff --git a/config.dot/awesome.link/awesompd b/config.dot/awesome.link/awesompd deleted file mode 160000 index 4142a7a..0000000 --- a/config.dot/awesome.link/awesompd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4142a7aa82e938afc7e948c3744ba2b0e520e495 diff --git a/config.dot/awesome.link/awesompd.lua b/config.dot/awesome.link/awesompd.lua deleted file mode 100644 index 4af25a3..0000000 --- a/config.dot/awesome.link/awesompd.lua +++ /dev/null @@ -1,57 +0,0 @@ -require("awesompd/awesompd") - -musicwidget = awesompd:create() -- Create awesompd widget ---musicwidget.font = "Liberation Mono" -- Set widget font -musicwidget.scrolling = true -- If true, the text in the widget will be scrolled -musicwidget.output_size = 30 -- Set the size of widget in symbols -musicwidget.update_interval = 10 -- Set the update interval in seconds --- Set the folder where icons are located (change username to your login name) -musicwidget.path_to_icons = configdir .. "/awesompd/icons" --- Set the default music format for Jamendo streams. You can change --- this option on the fly in awesompd itself. --- possible formats: awesompd.FORMAT_MP3, awesompd.FORMAT_OGG -musicwidget.jamendo_format = awesompd.FORMAT_MP3 --- If true, song notifications for Jamendo tracks and local tracks will also contain --- album cover image. -musicwidget.show_album_cover = false --- Specify how big in pixels should an album cover be. Maximum value --- is 100. -musicwidget.album_cover_size = 50 --- This option is necessary if you want the album covers to be shown --- for your local tracks. ---musicwidget.mpd_config = homedir .. "/.mpdconf" --- Specify the browser you use so awesompd can open links from --- Jamendo in it. -musicwidget.browser = "firefox" --- Specify decorators on the left and the right side of the --- widget. Or just leave empty strings if you decorate the widget --- from outside. -musicwidget.ldecorator = " " -musicwidget.rdecorator = " " --- Set all the servers to work with (here can be any servers you use) --- Set the buttons of the widget -musicwidget:register_buttons({ - --{ "", awesompd.MOUSE_LEFT, musicwidget:command_toggle() }, - --{ "Control", awesompd.MOUSE_SCROLL_UP, musicwidget:command_prev_track() }, - --{ "Control", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_next_track() }, - { "", "XF86AudioPrev", musicwidget:command_prev_track() }, - { "", "XF86AudioNext", musicwidget:command_next_track() }, - { modkey, "XF86AudioPrev", musicwidget:command_previous_server() }, - { modkey, "XF86AudioNext", musicwidget:command_next_server() }, - --{ "", awesompd.MOUSE_SCROLL_UP, musicwidget:command_volume_up() }, - --{ "", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_volume_down() }, - { "", awesompd.MOUSE_RIGHT, musicwidget:command_show_menu() }, - --{ "", "XF86AudioLowerVolume", musicwidget:command_volume_down() }, - --{ "", "XF86AudioRaiseVolume", musicwidget:command_volume_up() }, - --{ modkey, "Pause", musicwidget:command_playpause() } }) - { "", "XF86AudioPlay", musicwidget:command_playpause() } }) - --- Put your server definitions in this file, like this: ---musicwidget.servers = { --- { server = "localhost", --- port = 6600 }, --- { server = "192.168.0.72", --- port = 6600 } } -dofile(homedir .. "/.custom/awesome/awesompd.lua") - -musicwidget:run() -- After all configuration is done, run the widget diff --git a/config.dot/awesome.link/leds.lua b/config.dot/awesome.link/leds.lua deleted file mode 100644 index 382abdd..0000000 --- a/config.dot/awesome.link/leds.lua +++ /dev/null @@ -1,13 +0,0 @@ --- See https://bbs.archlinux.org/viewtopic.php?id=68511 -myledbox = widget({ type = "textbox" }) - -function run_leds() - local filedescripter = io.popen('leds') - local value = filedescripter:read() - filedescripter:close() - return value -end - -mytimer = timer({ timeout = 1 }) -mytimer:add_signal("timeout", function() myledbox.text = run_leds() end) -mytimer:start() diff --git a/config.dot/awesome.link/volume.lua b/config.dot/awesome.link/volume.lua deleted file mode 100644 index c183cb9..0000000 --- a/config.dot/awesome.link/volume.lua +++ /dev/null @@ -1,34 +0,0 @@ --- See http://awesome.naquadah.org/wiki/Volume_control_and_display -volume_widget = widget({ type = "textbox", name = "tb_volume", - align = "right" }) - -function update_volume(widget) - local fd = io.popen("amixer sget Master") - local status = fd:read("*all") - fd:close() - - local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100 - -- volume = string.format("% 3d", volume) - - status = string.match(status, "%[(o[^%]]*)%]") - - -- starting colour - local sr, sg, sb = 0x3F, 0x3F, 0x3F - -- ending colour - local er, eg, eb = 0xDC, 0xDC, 0xCC - - local ir = volume * (er - sr) + sr - local ig = volume * (eg - sg) + sg - local ib = volume * (eb - sb) + sb - interpol_colour = string.format("%.2x%.2x%.2x", ir, ig, ib) - if string.find(status, "on", 1, true) then - volume = " " - else - volume = " M " - end - widget.text = volume - end - -volumeTimer = timer({ timeout = 1 }) -volumeTimer:add_signal("timeout", function () update_volume(volume_widget) end) -volumeTimer:start() diff --git a/config.dot/awesome.link/widgets.lua b/config.dot/awesome.link/widgets.lua index f1ab01a..7cea6fd 100644 --- a/config.dot/awesome.link/widgets.lua +++ b/config.dot/awesome.link/widgets.lua @@ -1,10 +1,10 @@ -- {{{ Misc widgets -dofile(configdir .. "/leds.lua") -dofile(configdir .. "/volume.lua") +dofile(configdir .. "/widgets/leds.lua") +dofile(configdir .. "/widgets/volume.lua") if awful.util.file_readable(homedir .. "/.custom/awesome/awesompd.lua") then awesompd = true - dofile(configdir .. "/awesompd.lua") + dofile(configdir .. "/widgets/awesompd.lua") end -- }}} diff --git a/config.dot/awesome.link/widgets/awesompd b/config.dot/awesome.link/widgets/awesompd new file mode 160000 index 0000000..4142a7a --- /dev/null +++ b/config.dot/awesome.link/widgets/awesompd @@ -0,0 +1 @@ +Subproject commit 4142a7aa82e938afc7e948c3744ba2b0e520e495 diff --git a/config.dot/awesome.link/widgets/awesompd.lua b/config.dot/awesome.link/widgets/awesompd.lua new file mode 100644 index 0000000..4af25a3 --- /dev/null +++ b/config.dot/awesome.link/widgets/awesompd.lua @@ -0,0 +1,57 @@ +require("awesompd/awesompd") + +musicwidget = awesompd:create() -- Create awesompd widget +--musicwidget.font = "Liberation Mono" -- Set widget font +musicwidget.scrolling = true -- If true, the text in the widget will be scrolled +musicwidget.output_size = 30 -- Set the size of widget in symbols +musicwidget.update_interval = 10 -- Set the update interval in seconds +-- Set the folder where icons are located (change username to your login name) +musicwidget.path_to_icons = configdir .. "/awesompd/icons" +-- Set the default music format for Jamendo streams. You can change +-- this option on the fly in awesompd itself. +-- possible formats: awesompd.FORMAT_MP3, awesompd.FORMAT_OGG +musicwidget.jamendo_format = awesompd.FORMAT_MP3 +-- If true, song notifications for Jamendo tracks and local tracks will also contain +-- album cover image. +musicwidget.show_album_cover = false +-- Specify how big in pixels should an album cover be. Maximum value +-- is 100. +musicwidget.album_cover_size = 50 +-- This option is necessary if you want the album covers to be shown +-- for your local tracks. +--musicwidget.mpd_config = homedir .. "/.mpdconf" +-- Specify the browser you use so awesompd can open links from +-- Jamendo in it. +musicwidget.browser = "firefox" +-- Specify decorators on the left and the right side of the +-- widget. Or just leave empty strings if you decorate the widget +-- from outside. +musicwidget.ldecorator = " " +musicwidget.rdecorator = " " +-- Set all the servers to work with (here can be any servers you use) +-- Set the buttons of the widget +musicwidget:register_buttons({ + --{ "", awesompd.MOUSE_LEFT, musicwidget:command_toggle() }, + --{ "Control", awesompd.MOUSE_SCROLL_UP, musicwidget:command_prev_track() }, + --{ "Control", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_next_track() }, + { "", "XF86AudioPrev", musicwidget:command_prev_track() }, + { "", "XF86AudioNext", musicwidget:command_next_track() }, + { modkey, "XF86AudioPrev", musicwidget:command_previous_server() }, + { modkey, "XF86AudioNext", musicwidget:command_next_server() }, + --{ "", awesompd.MOUSE_SCROLL_UP, musicwidget:command_volume_up() }, + --{ "", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_volume_down() }, + { "", awesompd.MOUSE_RIGHT, musicwidget:command_show_menu() }, + --{ "", "XF86AudioLowerVolume", musicwidget:command_volume_down() }, + --{ "", "XF86AudioRaiseVolume", musicwidget:command_volume_up() }, + --{ modkey, "Pause", musicwidget:command_playpause() } }) + { "", "XF86AudioPlay", musicwidget:command_playpause() } }) + +-- Put your server definitions in this file, like this: +--musicwidget.servers = { +-- { server = "localhost", +-- port = 6600 }, +-- { server = "192.168.0.72", +-- port = 6600 } } +dofile(homedir .. "/.custom/awesome/awesompd.lua") + +musicwidget:run() -- After all configuration is done, run the widget diff --git a/config.dot/awesome.link/widgets/leds.lua b/config.dot/awesome.link/widgets/leds.lua new file mode 100644 index 0000000..382abdd --- /dev/null +++ b/config.dot/awesome.link/widgets/leds.lua @@ -0,0 +1,13 @@ +-- See https://bbs.archlinux.org/viewtopic.php?id=68511 +myledbox = widget({ type = "textbox" }) + +function run_leds() + local filedescripter = io.popen('leds') + local value = filedescripter:read() + filedescripter:close() + return value +end + +mytimer = timer({ timeout = 1 }) +mytimer:add_signal("timeout", function() myledbox.text = run_leds() end) +mytimer:start() diff --git a/config.dot/awesome.link/widgets/volume.lua b/config.dot/awesome.link/widgets/volume.lua new file mode 100644 index 0000000..c183cb9 --- /dev/null +++ b/config.dot/awesome.link/widgets/volume.lua @@ -0,0 +1,34 @@ +-- See http://awesome.naquadah.org/wiki/Volume_control_and_display +volume_widget = widget({ type = "textbox", name = "tb_volume", + align = "right" }) + +function update_volume(widget) + local fd = io.popen("amixer sget Master") + local status = fd:read("*all") + fd:close() + + local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100 + -- volume = string.format("% 3d", volume) + + status = string.match(status, "%[(o[^%]]*)%]") + + -- starting colour + local sr, sg, sb = 0x3F, 0x3F, 0x3F + -- ending colour + local er, eg, eb = 0xDC, 0xDC, 0xCC + + local ir = volume * (er - sr) + sr + local ig = volume * (eg - sg) + sg + local ib = volume * (eb - sb) + sb + interpol_colour = string.format("%.2x%.2x%.2x", ir, ig, ib) + if string.find(status, "on", 1, true) then + volume = " " + else + volume = " M " + end + widget.text = volume + end + +volumeTimer = timer({ timeout = 1 }) +volumeTimer:add_signal("timeout", function () update_volume(volume_widget) end) +volumeTimer:start() -- cgit v1.2.3