Improve cmus widget
This commit is contained in:
parent
d269ba7a19
commit
f07c629bda
|
@ -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.
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB |
|
@ -1,153 +0,0 @@
|
||||||
<?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>
|
|
Before Width: | Height: | Size: 6.3 KiB |
|
@ -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 path_to_icons = args.path_to_icons or "/usr/share/icons/Arc/actions/symbolic/"
|
||||||
local timeout = args.timeout or 10
|
local timeout = args.timeout or 10
|
||||||
|
|
||||||
cmus_widget = wibox.widget {
|
cmus_widget.widget = wibox.widget {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
id = "playback_icon",
|
id = "playback_icon",
|
||||||
|
@ -52,8 +52,7 @@ local function worker(user_args)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
watch("cmus-remote -Q", timeout,
|
function update_widget(widget, stdout, _, _, code)
|
||||||
function(widget, stdout, _, _, code)
|
|
||||||
if code == 0 then
|
if code == 0 then
|
||||||
local cmus_info = {}
|
local cmus_info = {}
|
||||||
|
|
||||||
|
@ -101,10 +100,25 @@ local function worker(user_args)
|
||||||
else
|
else
|
||||||
widget.visible = false
|
widget.visible = false
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
cmus_widget)
|
|
||||||
|
|
||||||
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
|
end
|
||||||
|
|
||||||
return setmetatable(cmus_widget, { __call = function(_, ...)
|
return setmetatable(cmus_widget, { __call = function(_, ...)
|
||||||
|
|
Loading…
Reference in New Issue