From 9b66b2ee444124df22543ccc38cd7b3b6302f994 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 16 Jan 2021 14:50:54 -0500 Subject: [PATCH] [brightness] rework brightness widget also remove brightnessarc widget, as now it's possible to create arcchart widget in brightness widget --- brightness-widget/README.md | 57 ++++----- brightness-widget/br-wid-1.png | Bin 1355 -> 4912 bytes brightness-widget/brightness.lua | 141 +++++++++++++++++------ brightness-widget/brightness.svg | 153 +++++++++++++++++++++++++ brightnessarc-widget/README.md | 97 ---------------- brightnessarc-widget/br-wid-1.png | Bin 1355 -> 0 bytes brightnessarc-widget/brightnessarc.lua | 77 ------------- 7 files changed, 281 insertions(+), 244 deletions(-) create mode 100644 brightness-widget/brightness.svg delete mode 100644 brightnessarc-widget/README.md delete mode 100644 brightnessarc-widget/br-wid-1.png delete mode 100644 brightnessarc-widget/brightnessarc.lua diff --git a/brightness-widget/README.md b/brightness-widget/README.md index 02aa2d3..5428029 100644 --- a/brightness-widget/README.md +++ b/brightness-widget/README.md @@ -1,6 +1,6 @@ # Brightness widget -This widget represents current brightness level: ![Brightness widget](./br-wid-1.png) +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 @@ -8,50 +8,39 @@ It is possible to customize widget by providing a table with all or some of the | Name | Default | Description | |---|---|---| -| `get_brightness_cmd` | `light -G` | Get current screen brightness | -| `inc_brightness_cmd` | `light -A 5` | Increase brightness | -| `dec_brightness_cmd` | `light -U 5`| Decrease brightness | +| `type`| `arc` | The widget type. Could be `arc` or `icon_and_text` | +| `program` | `light` | The program used to control the brightness, either 'light' or 'xbacklight'. | +| `step` | 5 | Step | | `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 | - -### Example: - -```lua -brightness_widget({ - get_brightness_cmd = 'xbacklight -get', - inc_brightness_cmd = 'xbacklight -inc 5', - dec_brightness_cmd = 'xbacklight -dec 5' -}) -``` +| `timeout` | 1 | How often in seconds the widget refreshes. Check the note below | +_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 -First you need to get the current brightness level. There are two options: +To choose the right `program` argument, first you need to check which of them works better for you. - - using `xbacklight` command (depending on your video card (I guess) it may or may not work) + - using `xbacklight`: - To check if it works install xbackligth and check if it works: + Install (on Ubuntu it's available in the apt repository) it and check if it works by running: ```bash - sudo apt-get install xbacklight xbacklight -get ``` - If there is no output it means that it doesn't work, but there is a second option: + 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 it from this git repo: [github.com/haikarainen/light](https://github.com/haikarainen/light) and check if it works but running + 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 - git clone https://github.com/haikarainen/light.git && \ - cd ./light && \ - sudo make && sudo make install \ 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. Then clone this repo under **~/.config/awesome/**: @@ -65,7 +54,7 @@ Require widget at the beginning of **rc.lua**: local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness") ``` -Add widget to the tasklist: +Add the widget to the tasklist: ```lua s.mytasklist, -- Middle widget @@ -75,13 +64,13 @@ s.mytasklist, -- Middle widget -- default brightness_widget(), -- or customized - brightness_widget({ - get_brightness_cmd = 'xbacklight -get', - inc_brightness_cmd = 'xbacklight -inc 5', - dec_brightness_cmd = 'xbacklight -dec 5' - }) + brightness_widget{ + type = 'icon_and_text', + program = 'xbacklight', + step = 2, + } } - ... + ... ``` ## Controls @@ -89,7 +78,7 @@ s.mytasklist, -- Middle widget In order to change brightness by shortcuts you can add them to the `globalkeys` table in the **rc.lua**: ```lua -awful.key({ modkey }, ";", function () awful.spawn("light -A 5") end, {description = "increase brightness", group = "custom"}), -awful.key({ modkey, "Shift"}, ";", function () awful.spawn("light -U 5") end, {description = "decrease brightness", group = "custom"}), +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 laptop you can use `XF86MonBrightnessUp` and `XF86MonBrightnessDown` keys. +On a laptop you can use `XF86MonBrightnessUp` and `XF86MonBrightnessDown` keys. diff --git a/brightness-widget/br-wid-1.png b/brightness-widget/br-wid-1.png index f9200ebec8db15a348e07caa12ca345635c2eb4f..b00b0e6091a08f4954e3a132648ddadb09163753 100644 GIT binary patch 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&BMVFBcAK(4%L3xI z+qEe;mJetRO63<)YMH`YqHS;*(TpI`@(wtlZN!00rU6zMGG%d{S!Cpg_^m~Q)-g_y z=odyv4U7xEvEAPuMW z{e(&aTAt79+{F9r!rI6e*HNf<0np!-lt7qkK&>- zthn*ycI2uiJ6c|2^9UON>xjlwlv~!EqTj3dP4=caU4|Oc(*Wz?fWBV}dglC!tTQe- zF#pZ=av-nGvQNC&K%UK3NLCJeB%q4{M&G2yXn}(O!`(Nq?i{(AdU`)uq3*g(*a+FU zAj&s2Vttv@XywBF7p}>sHcaWNN<|kv@**pI#zGC283OEQ!ITFHT0e-nH30fIV7%OJ zCR=ch{!T%LDmMCLY2lU;`5dFdPAC0fV)3nL%sjDml*PSm%|-fi+HEk9)nQ+qTWnK7 zwe?vf-v)*^j$jtDVnI&v!Dl4^K9Gb+{F#->p|}WNu(VM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ssh@YBSAr8=<+Wakf|i zKu72PKp@cE7+PDi#uclc-ZOKLw%mg-dp^1#@QERbu4Yhc%l2dZe1+E~e6bhWh3Cw_vE>?o> z<0stWg$<*4<%+MrJ!;!_=iWVo;mAlVHWG`?WFpLUanw8>)3g{O=Uhsq3Bd)Qo=#*x zdtS77X^t`y&`f<00EpD}>w~}b_1_u0d-v|WTX*h^PfVt$kg6hPt{jMB$zRdzPIR=4mo!l0hn|35|fHBN^vXO6fRWuh)?>BOQCn5=Q@h zv0})GNJ=S{vJpJ|!^ nP*6}1kH;BfETw_zoc{uRgfnx9lt0=40000<2SrXqu0mjf>)3TY diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua index 4686041..d5a79a9 100644 --- a/brightness-widget/brightness.lua +++ b/brightness-widget/brightness.lua @@ -5,66 +5,135 @@ -- https://github.com/streetturtle/awesome-wm-widgets/tree/master/brightness-widget -- @author Pavel Makhov --- @copyright 2017-2019 Pavel Makhov +-- @copyright 2021 Pavel Makhov ------------------------------------------------- +local awful = require("awful") local wibox = require("wibox") local watch = require("awful.widget.watch") local spawn = require("awful.spawn") +local naughty = require("naughty") -local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg" -local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get" -local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5" -local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 5" +local ICON_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/brightness-widget/' +local get_brightness_cmd +local inc_brightness_cmd +local dec_brightness_cmd local brightness_widget = {} +local function show_warning(message) + naughty.notify{ + preset = naughty.config.presets.critical, + title = 'Brightness Widget', + text = message} +end + local function worker(user_args) local args = user_args or {} - local get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD - local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD - local dec_brightness_cmd = args.dec_brightness_cmd or DEC_BRIGHTNESS_CMD - local path_to_icon = args.path_to_icon or PATH_TO_ICON + local type = args.type or 'arc' -- arc or icon_and_text + local path_to_icon = args.path_to_icon or ICON_DIR .. 'brightness.svg' local font = args.font or 'Play 9' - local timeout = args.timeout or 1 + local timeout = args.timeout or 100 - local brightness_text = wibox.widget.textbox() - brightness_text:set_font(font) + local program = args.program or 'light' + local step = args.step or 5 + if program == 'light' then + get_brightness_cmd = 'sh -c "light -G"' + inc_brightness_cmd = 'sh -c "light -A ' .. step .. '"' + dec_brightness_cmd = 'sh -c "light -U ' .. step .. '"' + elseif program == 'xbacklight' then + get_brightness_cmd = 'xbacklight -get' + inc_brightness_cmd = 'xbacklight -inc ' .. step + dec_brightness_cmd = 'xbacklight -dec ' .. step + else + show_warning(program .. " command is not supported by the widget") + return + end - local brightness_icon = wibox.widget { - { - image = path_to_icon, - resize = false, - widget = wibox.widget.imagebox, - }, - top = 3, - widget = wibox.container.margin - } + if type == 'icon_and_text' then + brightness_widget.widget = wibox.widget { + { + { + image = path_to_icon, + resize = false, + widget = wibox.widget.imagebox, + }, + valigh = 'center', + layout = wibox.container.place + }, + { + id = 'txt', + font = font, + widget = wibox.widget.textbox + }, + spacing = 4, + layout = wibox.layout.fixed.horizontal, + set_value = function(self, level) + self:get_children_by_id('txt')[1]:set_text(level .. '%') + end + } + elseif type == 'arc' then + brightness_widget.widget = wibox.widget { + { + { + image = path_to_icon, + resize = true, + widget = wibox.widget.imagebox, + }, + valigh = 'center', + layout = wibox.container.place + }, + max_value = 100, + thickness = 2, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = 18, + forced_width = 18, + bg = bg_color, + paddings = 2, + colors = {color}, + widget = wibox.container.arcchart, + set_value = function(self, level) + self:set_value(level) + end + } + else + show_warning(type .. " type is not supported by the widget") + return - brightness_widget = wibox.widget { - brightness_icon, - brightness_text, - layout = wibox.layout.fixed.horizontal, - } + end local update_widget = function(widget, stdout, _, _, _) local brightness_level = tonumber(string.format("%.0f", stdout)) - widget:set_text(" " .. brightness_level .. "%") + widget:set_value(brightness_level) end - brightness_widget:connect_signal("button::press", function(_, _, _, button) - if (button == 4) then - spawn(inc_brightness_cmd, false) - elseif (button == 5) then - spawn(dec_brightness_cmd, false) - end - end) + function brightness_widget:inc() + spawn.easy_async(inc_brightness_cmd, function() + spawn.easy_async(get_brightness_cmd, function(out) + update_widget(brightness_widget.widget, out) + end) + end) + end + function brightness_widget:dec() + spawn.easy_async(dec_brightness_cmd, function() + spawn.easy_async(get_brightness_cmd, function(out) + update_widget(brightness_widget.widget, out) + end) + end) + end - watch(get_brightness_cmd, timeout, update_widget, brightness_text) + brightness_widget.widget:buttons( + awful.util.table.join( + awful.button({}, 4, function() brightness_widget:inc() end), + awful.button({}, 5, function() brightness_widget:dec() end) + ) + ) - return brightness_widget + watch(get_brightness_cmd, timeout, update_widget, brightness_widget.widget) + + return brightness_widget.widget end return setmetatable(brightness_widget, { __call = function(_, ...) diff --git a/brightness-widget/brightness.svg b/brightness-widget/brightness.svg new file mode 100644 index 0000000..d334372 --- /dev/null +++ b/brightness-widget/brightness.svg @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/brightnessarc-widget/README.md b/brightnessarc-widget/README.md deleted file mode 100644 index c27f366..0000000 --- a/brightnessarc-widget/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# Brightness widget - -This widget represents current brightness level: ![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 | -|---|---|---| -| `get_brightness_cmd` | `light -G` | Get current screen brightness | -| `inc_brightness_cmd` | `light -A 5` | Increase brightness | -| `dec_brightness_cmd` | `light -U 5`| Decrease brightness | -| `color` | `beautiful.fg_color` | Color of the arc | -| `bg_color` | `#ffffff11` | Color of the arc's background | -| `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon | -| `timeout` | 1 | How often in seconds the widget refreshes | - -### Example: - -```lua -brightnessarc_widget({ - get_brightness_cmd = 'xbacklight -get', - inc_brightness_cmd = 'xbacklight -inc 5', - dec_brightness_cmd = 'xbacklight -dec 5' - color = '/usr/share/icons/Arc/status/symbolic/brightness-display-symbolic.svg' -}) -``` - - -## Installation - -First you need to get the current brightness level. There are two options: - - - using `xbacklight` command (depending on your video card (I guess) it may or may not work) - - To check if it works install xbackligth and check if it works: - - ```bash - sudo apt-get install xbacklight - xbacklight -get - ``` - - If there is no output it means that it doesn't work, but there is a second option: - - - using `light` command - - Install it from this git repo: [github.com/haikarainen/light](https://github.com/haikarainen/light) and check if it works but running - - ```bash - git clone https://github.com/haikarainen/light.git && \ - cd ./light && \ - sudo make && sudo make install \ - light -G - 49.18 - ``` - -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 brightnessarc_widget = require("awesome-wm-widgets.brightnessarc-widget.brightnessarc") -``` - -Add widget to the tasklist: - -```lua -s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - ... - -- default - brightnessarc_widget(), - -- or customized - brightnessarc_widget({ - get_brightness_cmd = 'xbacklight -get', - inc_brightness_cmd = 'xbacklight -inc 5', - dec_brightness_cmd = 'xbacklight -dec 5' - }) - } - ... -``` - -## 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 () awful.spawn("light -A 5") end, {description = "increase brightness", group = "custom"}), -awful.key({ modkey, "Shift"}, ";", function () awful.spawn("light -U 5") end, {description = "decrease brightness", group = "custom"}), -``` -On laptop you can use `XF86MonBrightnessUp` and `XF86MonBrightnessDown` keys. diff --git a/brightnessarc-widget/br-wid-1.png b/brightnessarc-widget/br-wid-1.png deleted file mode 100644 index f9200ebec8db15a348e07caa12ca345635c2eb4f..0000000000000000000000000000000000000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>w~}b_1_u0 zd-v|WTX*h^PfVt$kg6hPt{jM diff --git a/brightnessarc-widget/brightnessarc.lua b/brightnessarc-widget/brightnessarc.lua deleted file mode 100644 index fd37894..0000000 --- a/brightnessarc-widget/brightnessarc.lua +++ /dev/null @@ -1,77 +0,0 @@ -------------------------------------------------- --- Brightness Widget for Awesome Window Manager --- Shows the brightness level of the laptop display --- More details could be found here: --- https://github.com/streetturtle/awesome-wm-widgets/tree/master/widget-widget - --- @author Pavel Makhov --- @copyright 2019 Pavel Makhov -------------------------------------------------- - -local wibox = require("wibox") -local watch = require("awful.widget.watch") -local spawn = require("awful.spawn") -local beautiful = require("beautiful") - -local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg" -local GET_BRIGHTNESS_CMD = "light -G" -- "xbacklight -get" -local INC_BRIGHTNESS_CMD = "light -A 5" -- "xbacklight -inc 5" -local DEC_BRIGHTNESS_CMD = "light -U 5" -- "xbacklight -dec 5" - -local brightness_widget = {} - -local function worker(user_args) - - local args = user_args or {} - - local get_brightness_cmd = args.get_brightness_cmd or GET_BRIGHTNESS_CMD - local inc_brightness_cmd = args.inc_brightness_cmd or INC_BRIGHTNESS_CMD - local dec_brightness_cmd = args.dec_brightness_cmd or DEC_BRIGHTNESS_CMD - local color = args.color or beautiful.fg_color - local bg_color = args.bg_color or '#ffffff11' - local path_to_icon = args.path_to_icon or PATH_TO_ICON - local timeout = args.timeout or 1 - - local icon = { - id = "icon", - image = path_to_icon, - resize = true, - widget = wibox.widget.imagebox, - } - - brightness_widget = wibox.widget { - icon, - max_value = 1, - thickness = 2, - start_angle = 4.71238898, -- 2pi*3/4 - forced_height = 18, - forced_width = 18, - bg = bg_color, - paddings = 2, - colors = {color}, - widget = wibox.container.arcchart - } - - local update_widget = function(widget, stdout) - local brightness_level = string.match(stdout, "(%d?%d?%d?)") - brightness_level = tonumber(string.format("% 3d", brightness_level)) - - widget.value = brightness_level / 100; - end - - brightness_widget:connect_signal("button::press", function(_, _, _, button) - if (button == 4) then - spawn(inc_brightness_cmd, false) - elseif (button == 5) then - spawn(dec_brightness_cmd, false) - end - end) - - watch(get_brightness_cmd, timeout, update_widget, brightness_widget) - - return brightness_widget -end - -return setmetatable(brightness_widget, { __call = function(_, ...) - return worker(...) -end })