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 b00b0e6..0000000 Binary files a/config/awesome/cmus-widget/br-wid-1.png and /dev/null differ 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(_, ...)