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 zcmV-06VL34P)|+BiAmEOk<|DZ|VhX|QCOp{1as zk!k)&4S#@K(NYP+rIB9JD}o4@bKYnEc;D~W`Ef6hb=J9Sogd%*zVF@d-p_vav-cs| zyGSGHeH8!zl65b_Lx8}>VXxq1EyDp-BHZQJ7^&2dR%3MvL z0D^U=f`sI+w@7qbGF<^vlAs6*LU3=z*am?FP~5)(qXW%@R8oow z{5zO6MW)8@|3{8EJ>Xw_q&btxTA1(6w#m&B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pu-J9_~ zqD;q7<1($fMIZ3m(V4EQy@8J0@=0GF6%anq>KYtHY3UrUQ<-aqsCx{Tn{!H(;S$o zn=Yv8kfa*CK(A!ivPil0n_DF}D18)32Wa#(vuv*C7A)KHe_0SZ5IMW6kWRtS zM!<-Uo$D@H%2CB7iKTiyYfI*nCfQSIycBvi>9h~Mq>RQzY|YvqfgCi^zL*QzB|;h# zb=EJ*_FG$P*%G$;#_6Vb6hW9+=+W>zx zsZ_p%yi!FxS~%4lvNm1pc`(2+^1#ksw%BrKK|p-j}>3@|Zxn zd`{zCM)Go}w$VcBK(=)Wux^w1mQ5*@#6db=T1i z5`ZNUZGygBq|HnfnXL9lacVgohf&_E2%4;=(L*Wg-1-y;YmiUlngJ>h(N-Y5uc{UB zrA^yX)206gc++t|WAj0FfoL)&?psx=Abl3KM2ilnO~p*~EqfdR>yL|LiT ztgXrpO+#8q z9j1ONrH)!=V!>*Vb9KaDN$x2>@1PLNU;3h{|m?r@?xg){7{aJd`>~uF^R`pfo^g(h4fSy8_?)ez{ha7fQBp`hi7{$4gG=aK zI_DE*he%su2$yJJkg-{x80u!6SvSQHF`?j=RP(w^stbtt0}{f_B_iczF7fh^%p6N| zUHy#TwEB$;!>m)0C#f;GN-0j+q(&KnA}G2nnMv75jsZch@sgJ>*1@e991F&+FD}z@ z*FvS|i__W}&#?v~rn*n$tMUoxMAW - - - - - - - - - - - - - - - - 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(_, ...)