Add cmus widget
This commit is contained in:
parent
26ce5a88f4
commit
d269ba7a19
|
@ -0,0 +1,93 @@
|
||||||
|
# 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.
|
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
|
@ -0,0 +1,153 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
id="svg2"
|
||||||
|
sodipodi:version="0.32"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
version="1.0"
|
||||||
|
sodipodi:docname="display-brightness-symbolic.svg"
|
||||||
|
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||||
|
style="display:inline">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#e7e7e7"
|
||||||
|
borderopacity="1"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="44.218752"
|
||||||
|
inkscape:cx="12.155025"
|
||||||
|
inkscape:cy="7.6228779"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
showguides="false"
|
||||||
|
inkscape:guide-bbox="true"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1029"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="24"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:snap-global="true">
|
||||||
|
<sodipodi:guide
|
||||||
|
orientation="1,0"
|
||||||
|
position="0,112"
|
||||||
|
id="guide2383" />
|
||||||
|
<sodipodi:guide
|
||||||
|
orientation="0,1"
|
||||||
|
position="26.278146,128"
|
||||||
|
id="guide2385" />
|
||||||
|
<sodipodi:guide
|
||||||
|
orientation="1,0"
|
||||||
|
position="128,54.082119"
|
||||||
|
id="guide2387" />
|
||||||
|
<sodipodi:guide
|
||||||
|
orientation="0,1"
|
||||||
|
position="78.156291,0"
|
||||||
|
id="guide2389" />
|
||||||
|
<sodipodi:guide
|
||||||
|
orientation="0,1"
|
||||||
|
position="60.863576,64.084768"
|
||||||
|
id="guide2391" />
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid3672"
|
||||||
|
visible="true"
|
||||||
|
enabled="true"
|
||||||
|
empspacing="8"
|
||||||
|
snapvisiblegridlinesonly="true" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Icon"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
style="display:inline"
|
||||||
|
transform="translate(0,-6)">
|
||||||
|
<path
|
||||||
|
style="color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
d="m -12,6 -1,3 2,0 -1,-3 z m -5.65625,2.34375 1.40625,2.8125 1.40625,-1.40625 -2.8125,-1.40625 z m 11.3125,0 L -9.15625,9.75 -7.75,11.15625 -6.34375,8.34375 z M -12,10 c -2.209139,0 -4,1.790861 -4,4 0,2.209139 1.790861,4 4,4 2.209139,0 4,-1.790861 4,-4 0,-2.209139 -1.790861,-4 -4,-4 z m 0,1.5 c 1.380712,0 2.5,1.119288 2.5,2.5 0,1.380712 -1.119288,2.5 -2.5,2.5 -1.380712,0 -2.5,-1.119288 -2.5,-2.5 0,-1.380712 1.119288,-2.5 2.5,-2.5 z m -5,1.5 -3,1 3,1 0,-2 z m 10,0 0,2 3,-1 -3,-1 z m -9.25,3.84375 -1.40625,2.8125 2.8125,-1.40625 -1.40625,-1.40625 z m 8.5,0 -1.40625,1.40625 2.8125,1.40625 L -7.75,16.84375 z M -13,19 l 1,3 1,-3 -2,0 z"
|
||||||
|
id="path3085"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
id="path3102"
|
||||||
|
d="m 8,30 c -2.209139,0 -4,1.790861 -4,4 0,2.209139 1.790861,4 4,4 2.209139,0 4,-1.790861 4,-4 0,-2.209139 -1.790861,-4 -4,-4 z m 0,2 c 1.1045695,0 2,0.89543 2,2 0,1.104569 -0.8954305,2 -2,2 -1.1045695,0 -2,-0.895431 -2,-2 0,-1.10457 0.8954305,-2 2,-2 z"
|
||||||
|
style="opacity:0.35;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-y="-6.5"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path3104"
|
||||||
|
d="m 6,29 4,0 -2,-3 z"
|
||||||
|
style="fill:#808080;stroke:none" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-y="-2.4999999"
|
||||||
|
inkscape:transform-center-x="-5.1291655"
|
||||||
|
style="fill:#808080;stroke:none"
|
||||||
|
d="m 11.330127,29.767949 2,3.464102 L 14.928204,30 z"
|
||||||
|
id="path3106"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc" />
|
||||||
|
<path
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path3108"
|
||||||
|
d="m 13.330127,34.767949 -2,3.464102 L 14.928203,38 z"
|
||||||
|
style="fill:#808080;stroke:none"
|
||||||
|
inkscape:transform-center-x="-5.129165"
|
||||||
|
inkscape:transform-center-y="2.5" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-y="6.5"
|
||||||
|
style="fill:#808080;stroke:none"
|
||||||
|
d="m 10,39 -4.0000002,0 2.0000001,3 z"
|
||||||
|
id="path3110"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-x="5.1291651"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path3112"
|
||||||
|
d="M 4.6698729,38.232051 2.6698728,34.767949 1.0717967,38 z"
|
||||||
|
style="fill:#808080;stroke:none"
|
||||||
|
inkscape:transform-center-y="2.5" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-y="-2.5"
|
||||||
|
style="fill:#808080;stroke:none"
|
||||||
|
d="M 2.6698727,33.232051 4.669873,29.767949 1.0717967,30 z"
|
||||||
|
id="path3114"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc"
|
||||||
|
inkscape:transform-center-x="5.129165" />
|
||||||
|
<path
|
||||||
|
style="color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
d="M 5.84375 0 L 5.09375 2.96875 L 2.15625 2.15625 L 2.96875 5.09375 L 0 5.84375 L 2.1875 8 L 0 10.15625 L 2.96875 10.90625 L 2.15625 13.84375 L 5.09375 13.03125 L 5.84375 16 L 8 13.8125 L 10.15625 16 L 10.90625 13.03125 L 13.84375 13.84375 L 13.03125 10.90625 L 16 10.15625 L 13.8125 8 L 16 5.84375 L 13.03125 5.09375 L 13.84375 2.15625 L 10.90625 2.96875 L 10.15625 0 L 8 2.1875 L 5.84375 0 z M 8 3 C 10.761424 3 13 5.2385763 13 8 C 13 10.761424 10.761424 13 8 13 L 8 3 z "
|
||||||
|
transform="translate(0,6)"
|
||||||
|
id="path3075" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 6.3 KiB |
|
@ -0,0 +1,112 @@
|
||||||
|
-------------------------------------------------
|
||||||
|
-- Cmus Widget for Awesome Window Manager
|
||||||
|
-- Show what's playing, play/pause, etc
|
||||||
|
|
||||||
|
-- @author Augusto Gunsch
|
||||||
|
-- @copyright 2022 Augusto Gunsch
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
local awful = require("awful")
|
||||||
|
local wibox = require("wibox")
|
||||||
|
local watch = require("awful.widget.watch")
|
||||||
|
local spawn = require("awful.spawn")
|
||||||
|
local naughty = require("naughty")
|
||||||
|
|
||||||
|
local cmus_widget = {}
|
||||||
|
|
||||||
|
local function show_warning(message)
|
||||||
|
naughty.notify{
|
||||||
|
preset = naughty.config.presets.critical,
|
||||||
|
title = "Cmus Widget",
|
||||||
|
text = message}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function worker(user_args)
|
||||||
|
|
||||||
|
local args = user_args or {}
|
||||||
|
local font = args.font or "Play 9"
|
||||||
|
|
||||||
|
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 {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
id = "playback_icon",
|
||||||
|
resize = false,
|
||||||
|
widget = wibox.widget.imagebox,
|
||||||
|
},
|
||||||
|
layout = wibox.container.place
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = "text",
|
||||||
|
font = font,
|
||||||
|
widget = wibox.widget.textbox
|
||||||
|
},
|
||||||
|
layout = wibox.layout.fixed.horizontal,
|
||||||
|
update_icon = function(self, name)
|
||||||
|
self:get_children_by_id("playback_icon")[1]:set_image(path_to_icons .. name)
|
||||||
|
end,
|
||||||
|
set_title = function(self, title)
|
||||||
|
self:get_children_by_id("text")[1]:set_text(title)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
watch("cmus-remote -Q", timeout,
|
||||||
|
function(widget, stdout, _, _, code)
|
||||||
|
if code == 0 then
|
||||||
|
local cmus_info = {}
|
||||||
|
|
||||||
|
for s in stdout:gmatch("[^\r\n]+") do
|
||||||
|
local key, val = string.match(s, "^tag (%a+) (.+)$")
|
||||||
|
|
||||||
|
if key and val then
|
||||||
|
cmus_info[key] = val
|
||||||
|
else
|
||||||
|
local key, val = string.match(s, "^set (%a+) (.+)$")
|
||||||
|
|
||||||
|
if key and val then
|
||||||
|
cmus_info[key] = val
|
||||||
|
else
|
||||||
|
local key, val = string.match(s, "^(%a+) (.+)$")
|
||||||
|
if key and val then
|
||||||
|
cmus_info[key] = val
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local title = cmus_info.title
|
||||||
|
|
||||||
|
if not title and cmus_info.file then
|
||||||
|
title = cmus_info.file:gsub("%..-$", "")
|
||||||
|
title = title:gsub("^.+/", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
if title then
|
||||||
|
if cmus_info["status"] == "playing" then
|
||||||
|
widget:update_icon("media-playback-start-symbolic.svg")
|
||||||
|
elseif cmus_info["status"] == "paused" then
|
||||||
|
widget:update_icon("media-playback-pause-symbolic.svg")
|
||||||
|
else
|
||||||
|
widget:update_icon("media-playback-stop-symbolic.svg")
|
||||||
|
end
|
||||||
|
|
||||||
|
widget:set_title(title)
|
||||||
|
widget.visible = true
|
||||||
|
else
|
||||||
|
widget.visible = false
|
||||||
|
widget.width = 0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
widget.visible = false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
cmus_widget)
|
||||||
|
|
||||||
|
return cmus_widget
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(cmus_widget, { __call = function(_, ...)
|
||||||
|
return worker(...)
|
||||||
|
end })
|
|
@ -23,6 +23,7 @@ local is_deb, debian = pcall(require, "debian.menu")
|
||||||
local has_fdo, freedesktop = pcall(require, "freedesktop")
|
local has_fdo, freedesktop = pcall(require, "freedesktop")
|
||||||
|
|
||||||
-- awesome-wm-widgets
|
-- awesome-wm-widgets
|
||||||
|
local cmus_widget = require("cmus-widget.cmus")
|
||||||
local volume_widget = require("awesome-wm-widgets.volume-widget.volume")
|
local volume_widget = require("awesome-wm-widgets.volume-widget.volume")
|
||||||
local battery_widget = require("awesome-wm-widgets.battery-widget.battery")
|
local battery_widget = require("awesome-wm-widgets.battery-widget.battery")
|
||||||
local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness")
|
local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness")
|
||||||
|
@ -247,10 +248,14 @@ awful.screen.connect_for_each_screen(function(s)
|
||||||
s.mypromptbox,
|
s.mypromptbox,
|
||||||
},
|
},
|
||||||
s.mytasklist, -- Middle widget
|
s.mytasklist, -- Middle widget
|
||||||
{ -- Right widgets
|
{
|
||||||
|
layout = wibox.layout.fixed.horizontal,
|
||||||
|
{
|
||||||
|
widget = wibox.container.margin,
|
||||||
|
right = 4,
|
||||||
|
{
|
||||||
layout = wibox.layout.fixed.horizontal,
|
layout = wibox.layout.fixed.horizontal,
|
||||||
spacing = 10,
|
spacing = 10,
|
||||||
--mykeyboardlayout,
|
|
||||||
wibox.widget.separator{
|
wibox.widget.separator{
|
||||||
orientation = "vertical",
|
orientation = "vertical",
|
||||||
forced_width = 5,
|
forced_width = 5,
|
||||||
|
@ -260,23 +265,40 @@ awful.screen.connect_for_each_screen(function(s)
|
||||||
wibox.widget.separator{
|
wibox.widget.separator{
|
||||||
orientation = "vertical",
|
orientation = "vertical",
|
||||||
forced_width = 5
|
forced_width = 5
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
battery_widget{
|
{
|
||||||
enable_battery_warning = true
|
cmus_widget(),
|
||||||
},
|
widget = wibox.container.margin,
|
||||||
brightness_widget {
|
right = 5,
|
||||||
type = 'icon_and_text',
|
left = 5,
|
||||||
program = 'brightnessctl',
|
draw_empty = false
|
||||||
percentage = false
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
widget = wibox.container.margin,
|
||||||
|
left = 6,
|
||||||
|
{
|
||||||
|
layout = wibox.layout.fixed.horizontal,
|
||||||
|
spacing = 10,
|
||||||
volume_widget{
|
volume_widget{
|
||||||
widget_type = 'icon_and_text',
|
widget_type = 'icon_and_text',
|
||||||
with_icon = true,
|
with_icon = true,
|
||||||
mute_color = beautiful.bg_urgent
|
mute_color = beautiful.bg_urgent
|
||||||
},
|
},
|
||||||
|
--battery_widget{
|
||||||
|
--enable_battery_warning = true
|
||||||
|
--},
|
||||||
|
--brightness_widget {
|
||||||
|
--type = 'icon_and_text',
|
||||||
|
--program = 'brightnessctl',
|
||||||
|
--percentage = false
|
||||||
|
--},
|
||||||
mytextclock,
|
mytextclock,
|
||||||
s.mylayoutbox,
|
s.mylayoutbox,
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
Loading…
Reference in New Issue