From f07c629bdaff623c1d8fedad71bcaf1091019230 Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Sun, 23 Jan 2022 19:57:24 -0300 Subject: [PATCH] Improve cmus widget --- config/awesome/cmus-widget/README.md | 93 ------------- config/awesome/cmus-widget/br-wid-1.png | Bin 4912 -> 0 bytes config/awesome/cmus-widget/brightness.svg | 153 ---------------------- config/awesome/cmus-widget/cmus.lua | 26 +++- 4 files changed, 20 insertions(+), 252 deletions(-) delete mode 100644 config/awesome/cmus-widget/README.md delete mode 100644 config/awesome/cmus-widget/br-wid-1.png delete mode 100644 config/awesome/cmus-widget/brightness.svg diff --git a/config/awesome/cmus-widget/README.md b/config/awesome/cmus-widget/README.md deleted file mode 100644 index cbf5b7e..0000000 --- a/config/awesome/cmus-widget/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# Brightness widget - -This widget represents current brightness level, depending on config parameters could be an arcchart or icon with text: ![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 | -|---|---|---| -| `type`| `arc` | The widget type. Could be `arc` or `icon_and_text` | -| `program` | `light` | The program used to control the brightness, either `light`, `xbacklight`, or `brightnessctl`. | -| `step` | 5 | Step | -| `base` | 20 | Base level to set brightness to on left click. | -| `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon | -| `font` | `Play 9` | Font | -| `timeout` | 1 | How often in seconds the widget refreshes. Check the note below | -| `tooltip` | false | Display brightness level in a tooltip when the mouse cursor hovers the widget | - -_Note:_ If brightness is controlled only by the widget (either by a mouse, or by a shortcut, then the `timeout` could be quite big, as there is no reason to synchronize the brightness level). - -## Installation - -To choose the right `program` argument, first you need to check which of them works better for you. - - - using `xbacklight`: - - Install (on Ubuntu it's available in the apt repository) it and check if it works by running: - - ```bash - xbacklight -get - ``` - - If there is no output it means that it doesn't work, you can either try to fix it, or try to use `light`. - - - using `light` command: - - Install (on Ubuntu it's available in the apt repository) from the repo: [github.com/haikarainen/light](https://github.com/haikarainen/light) and check if it works by running - - ```bash - light -G - 49.18 - light -A 5 - ``` - If you're on Ubuntu/debian and if the brightness level doesn't change, try to do this: https://github.com/haikarainen/light/issues/113#issuecomment-632638436. - - - using `brightnessctl`: - - On Ubuntu it is available in the apt repository. Install and check the ouptut of the following command. - ```bash - brightnessctl --list - ``` - -Then clone this repo under **~/.config/awesome/**: - -```bash -git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/awesome-wm-widgets -``` - -Require widget at the beginning of **rc.lua**: - -```lua -local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness") -``` - -Add the widget to the tasklist: - -```lua -s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - ... - -- default - brightness_widget(), - -- or customized - brightness_widget{ - type = 'icon_and_text', - program = 'xbacklight', - step = 2, - } - } - ... -``` - -## Controls - -In order to change brightness by shortcuts you can add them to the `globalkeys` table in the **rc.lua**: - -```lua -awful.key({ modkey }, ";", function () brightness_widget:inc() end, {description = "increase brightness", group = "custom"}), -awful.key({ modkey, "Shift"}, ";", function () brightness_widget:dec() end, {description = "decrease brightness", group = "custom"}), -``` -On a laptop you can use `XF86MonBrightnessUp` and `XF86MonBrightnessDown` keys. diff --git a/config/awesome/cmus-widget/br-wid-1.png b/config/awesome/cmus-widget/br-wid-1.png deleted file mode 100644 index b00b0e6091a08f4954e3a132648ddadb09163753..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4912 zcmeAS@N?(olHy`uVBq!ia0y~yU?^r_V9?`WVqjpHVz_Yz0|Ntdv6E*A2M5RPhyD*3 z7#IXfTq8N>YoGn=WuNFbJLTba4#HxVJaDe#_L6yZ5%a&el>0O!>88z{ih2>+N(xABaZb|5e<7fBk2n{)EzNJG1A?-~YSs{oVKX&ewh0 z{9W9A{-+hUlX+66lqXxW+f7=)!R1ttfAj`hBTK-Y z{fvv5&o+kyb#eZ&o?+^`?AZJ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FE%OhRnOlWTUrjq-RyAHD!qP@SExZ%Ft=%6%#yP{qBGZgb1%%Ylx+{Zx0++t znxz+=HDBNPCBmLP!T<3rMlFGhVG4WJuM+*R)c1DK<)#1GDlQk=r`fwEF6_AdO3#lo zrL!c;u63V9Q-(>Ue&e$s?vAvLdgf{mpUeB)-q)J4hHVaivG3L`N4Q<{cV;d8#3Owt zq%`x^EZ-c(%DlJ** zRGZkRiQlF)7(2PWYdgvk_rf(LmgT9<-VOZEgl060pE;xIxFjuz(Km5jcgo(@8%akr zoezY$UB4E&t)O1Aos%If#mVqOX2+>qv*ib?W?$>pm}xV`%5&W%ONWIqH)lOODdc(L zS>qmYh4(X6iY6s^x;CuO6ZG(YFl9>pgNqNg@y=OOz`69%L$fo71Hi%7( z=5LEwWx`KsbRTYfdP`oiZ5dBv!6g1mGdWH;%6<9E$hd+u-f)ysW&P4GnZm4-XKH2rQaag%IP(%7Xl)AOcBAEV>?kCUeBUpu%~ zLWcX;T7A9Ch1Z>yKJUJKOY;0iHl<~|{GY7;#QDPI${uzfO@CiDx&4_|pCTmqdIXPM zdQrPS*kPf>vPC=I8Qb$O<2lGL6~pvgVoFg(Wq%g$3L(wrbN@r`&reSL(Ry~-r{aT7 zy!Kb63vLJTMXj!Uy;=5FR>{5UOG&$@{;9t+?c@KWmpzRb7#J8lUHx3vIVCg!0CYOh A`~Uy| diff --git a/config/awesome/cmus-widget/brightness.svg b/config/awesome/cmus-widget/brightness.svg deleted file mode 100644 index d334372..0000000 --- a/config/awesome/cmus-widget/brightness.svg +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - diff --git a/config/awesome/cmus-widget/cmus.lua b/config/awesome/cmus-widget/cmus.lua index c0d4e00..dd5f797 100644 --- a/config/awesome/cmus-widget/cmus.lua +++ b/config/awesome/cmus-widget/cmus.lua @@ -29,7 +29,7 @@ local function worker(user_args) local path_to_icons = args.path_to_icons or "/usr/share/icons/Arc/actions/symbolic/" local timeout = args.timeout or 10 - cmus_widget = wibox.widget { + cmus_widget.widget = wibox.widget { { { id = "playback_icon", @@ -52,8 +52,7 @@ local function worker(user_args) end } - watch("cmus-remote -Q", timeout, - function(widget, stdout, _, _, code) + function update_widget(widget, stdout, _, _, code) if code == 0 then local cmus_info = {} @@ -101,10 +100,25 @@ local function worker(user_args) else widget.visible = false end - end, - cmus_widget) + end - return cmus_widget + function cmus_widget:play_pause() + spawn("cmus-remote -u") + spawn.easy_async("cmus-remote -Q", + function(stdout, _, _, code) + update_widget(cmus_widget.widget, stdout, _, _, code) + end) + end + + cmus_widget.widget:buttons( + awful.util.table.join( + awful.button({}, 1, function() cmus_widget:play_pause() end) + ) + ) + + watch("cmus-remote -Q", timeout, update_widget, cmus_widget.widget) + + return cmus_widget.widget end return setmetatable(cmus_widget, { __call = function(_, ...)