summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml2
-rwxr-xr-x.github/workflows/update-site.yml43
-rw-r--r--CODEOWNERS1
-rw-r--r--README.md2
-rw-r--r--apt-widget/apt-widget.lua2
-rw-r--r--battery-widget/README.md3
-rw-r--r--battery-widget/battery.lua4
-rw-r--r--batteryarc-widget/batteryarc.lua2
-rw-r--r--brightness-widget/README.md1
-rw-r--r--brightness-widget/brightness.lua7
-rw-r--r--calendar-widget/README.md6
-rw-r--r--calendar-widget/calendar_start_sunday.pngbin0 -> 8410 bytes
-rw-r--r--cmus-widget/README.md51
-rw-r--r--cmus-widget/cmus.lua127
-rw-r--r--cmus-widget/screenshots/cmus-widget.pngbin0 -> 6959 bytes
-rw-r--r--logout-menu-widget/README.md2
-rwxr-xr-xscripts/update_site.sh14
-rw-r--r--spotify-widget/spotify.lua6
18 files changed, 261 insertions, 12 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1bfeee3..bdb08e1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -8,6 +8,8 @@ on:
push:
branches:
- '*'
+ paths:
+ - '**.lua'
pull_request:
branches: [ master ]
diff --git a/.github/workflows/update-site.yml b/.github/workflows/update-site.yml
new file mode 100755
index 0000000..7415c2e
--- /dev/null
+++ b/.github/workflows/update-site.yml
@@ -0,0 +1,43 @@
+name: update site
+
+on:
+ push:
+ branches:
+ - 'master'
+ paths:
+ - '**/README.md'
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Generate md
+ run: ./scripts/update_site.sh
+
+ - name: Push to gh-pages branch
+ run: |
+ git config --global user.name 'GitHub Action'
+ git config --global user.email 'action@github.com'
+ git add ./_widgets
+ git add ./assets/img/widgets
+ git stash
+ git fetch
+ echo "git checkout gh-pages"
+ git checkout gh-pages
+ rm -rf ./_widgets
+ rm -rf ./assets/img/widgets
+ ls -alF
+ echo "git stash pop"
+ git checkout stash -- ./_widgets
+ git checkout stash -- ./assets/img/widgets
+ git add ./_widgets
+ git add ./assets/img/widgets
+ git commit -m "update from master"
+ git push origin gh-pages
+
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000..0661fff
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1 @@
+* @streetturtle
diff --git a/README.md b/README.md
index 1521a63..1617fae 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ Clone the repo under **~/.config/awesome/**, then follow an Installation section
In case of any doubts/questions/problems:
- create an [issue](https://github.com/streetturtle/awesome-wm-widgets/issues/new/choose)
- raise a question on [Discussions](https://github.com/streetturtle/awesome-wm-widgets/discussions)!
- - ping me on AwesomeWM's discord, here's an [invite](https://discord.gg/XYvn8R5)
+ - ping me on AwesomeWM's discord, here's an [invite](https://discord.gg/BPat4F87dg)
# Support
diff --git a/apt-widget/apt-widget.lua b/apt-widget/apt-widget.lua
index 61aa3b5..c15c32f 100644
--- a/apt-widget/apt-widget.lua
+++ b/apt-widget/apt-widget.lua
@@ -19,7 +19,7 @@ local HOME_DIR = os.getenv("HOME")
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/apt-widget'
local ICONS_DIR = WIDGET_DIR .. '/icons/'
-local LIST_PACKAGES = [[sh -c "apt list --upgradable 2>/dev/null"]]
+local LIST_PACKAGES = [[sh -c "LC_ALL=c apt list --upgradable 2>/dev/null"]]
--- Utility function to show warning messages
local function show_warning(message)
diff --git a/battery-widget/README.md b/battery-widget/README.md
index 9af7a4c..b15aac6 100644
--- a/battery-widget/README.md
+++ b/battery-widget/README.md
@@ -35,7 +35,7 @@ It is possible to customize widget by providing a table with all or some of the
| `warning_msg_icon` | ~/.config/awesome/awesome-wm-widgets/battery-widget/spaceman.jpg | Icon of the warning popup |
| `enable_battery_warning` | `true` | Display low battery warning |
-*Note: the widget expects following icons be present in the folder:
+*Note: the widget expects following icons to be present in the folder:
- battery-caution-charging-symbolic.svg
- battery-empty-charging-symbolic.svg
@@ -53,6 +53,7 @@ It is possible to customize widget by providing a table with all or some of the
## Installation
This widget reads the output of acpi tool.
+
- install `acpi` and check the output:
```bash
diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua
index fc8c56f..452d7ef 100644
--- a/battery-widget/battery.lua
+++ b/battery-widget/battery.lua
@@ -125,7 +125,7 @@ local function worker(user_args)
local battery_info = {}
local capacities = {}
for s in stdout:gmatch("[^\r\n]+") do
- local status, charge_str, _ = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
+ local status, charge_str, _ = string.match(s, '.+: ([%a%s]+), (%d?%d?%d)%%,?(.*)')
if status ~= nil then
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
else
@@ -157,7 +157,7 @@ local function worker(user_args)
level_widget.text = string.format('%d%%', charge)
end
- if (charge >= 0 and charge < 15) then
+ if (charge >= 1 and charge < 15) then
batteryType = "battery-empty%s-symbolic"
if enable_battery_warning and status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then
-- if 5 minutes have elapsed since the last warning
diff --git a/batteryarc-widget/batteryarc.lua b/batteryarc-widget/batteryarc.lua
index 1b6752a..3d38af4 100644
--- a/batteryarc-widget/batteryarc.lua
+++ b/batteryarc-widget/batteryarc.lua
@@ -89,7 +89,7 @@ local function worker(user_args)
local charge = 0
local status
for s in stdout:gmatch("[^\r\n]+") do
- local cur_status, charge_str, _ = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
+ local cur_status, charge_str, _ = string.match(s, '.+: ([%a%s]+), (%d?%d?%d)%%,?(.*)')
if cur_status ~= nil and charge_str ~=nil then
local cur_charge = tonumber(charge_str)
if cur_charge > charge then
diff --git a/brightness-widget/README.md b/brightness-widget/README.md
index 936c881..0cdb774 100644
--- a/brightness-widget/README.md
+++ b/brightness-widget/README.md
@@ -16,6 +16,7 @@ It is possible to customize widget by providing a table with all or some of the
| `font` | `beautiful.font` | Font name and size, like `Play 12` |
| `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 |
+| `percentage` | false | Display a '%' character after the brightness level |
_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).
diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua
index b9f07c9..3a77a44 100644
--- a/brightness-widget/brightness.lua
+++ b/brightness-widget/brightness.lua
@@ -44,6 +44,7 @@ local function worker(user_args)
local base = args.base or 20
local current_level = 0 -- current brightness value
local tooltip = args.tooltip or false
+ local percentage = args.percentage or false
if program == 'light' then
get_brightness_cmd = 'light -G'
set_brightness_cmd = 'light -S %d' -- <level>
@@ -83,7 +84,11 @@ local function worker(user_args)
spacing = 4,
layout = wibox.layout.fixed.horizontal,
set_value = function(self, level)
- self:get_children_by_id('txt')[1]:set_text(level .. '%')
+ local display_level = level
+ if percentage then
+ display_level = display_level .. '%'
+ end
+ self:get_children_by_id('txt')[1]:set_text(display_level)
end
}
elseif type == 'arc' then
diff --git a/calendar-widget/README.md b/calendar-widget/README.md
index e354c07..b663a18 100644
--- a/calendar-widget/README.md
+++ b/calendar-widget/README.md
@@ -9,9 +9,9 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
| Name | Default | Description |
|---|---|---|
-| theme | `naughty` | The theme to use |
-| placement | `top` | The position of the popup |
-| radius | 8 | The popup radius |
+| theme | `naughty` | The theme to use |
+| placement | `top` | The position of the popup |
+| radius | 8 | The popup radius |
| start_sunday | false | Start the week on Sunday |
- themes:
diff --git a/calendar-widget/calendar_start_sunday.png b/calendar-widget/calendar_start_sunday.png
new file mode 100644
index 0000000..126a218
--- /dev/null
+++ b/calendar-widget/calendar_start_sunday.png
Binary files differ
diff --git a/cmus-widget/README.md b/cmus-widget/README.md
new file mode 100644
index 0000000..7e7fb9e
--- /dev/null
+++ b/cmus-widget/README.md
@@ -0,0 +1,51 @@
+# Cmus widget
+
+Cmus widget that shows the current playing track.
+
+![widget](./screenshots/cmus-widget.png)
+
+Left click toggles playback.
+
+## Installation
+
+Clone the repo under **~/.config/awesome/** and add widget in **rc.lua**:
+
+```lua
+local cmus_widget = require('awesome-wm-widgets.cmus-widget.cmus')
+...
+s.mytasklist, -- Middle widget
+ { -- Right widgets
+ layout = wibox.layout.fixed.horizontal,
+ ...
+ -- default
+ cmus_widget(),
+ -- customized
+ cmus_widget{
+ space = 5,
+ timeout = 5
+ },
+```
+
+### Shortcuts
+
+To improve responsiveness of the widget when playback is changed by a shortcut use corresponding methods of the widget:
+
+```lua
+awful.key({ modkey, "Shift" },
+ "p",
+ function() cmus_widget:play_pause() end,
+ {description = "play/pause cmus", group = "custom"}),
+```
+
+## Customization
+
+It is possible to customize the widget by providing a table with all or some of the following config parameters:
+
+### Generic parameter
+
+| Name | Default | Description |
+|---|---|---|
+| `font` | `Play 9` | Font used for the track title |
+| `path_to_icons` | `/usr/share/icons/Arc/actions/symbolic/` | Alternative path for the icons |
+| `timeout`| `10` | Refresh cooldown |
+| `space` | `3` | Space between icon and track title |
diff --git a/cmus-widget/cmus.lua b/cmus-widget/cmus.lua
new file mode 100644
index 0000000..51daa89
--- /dev/null
+++ b/cmus-widget/cmus.lua
@@ -0,0 +1,127 @@
+-------------------------------------------------
+-- 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
+ local space = args.space or 3
+
+ cmus_widget.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
+ }
+
+ function update_widget(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
+
+ 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(_, ...)
+ return worker(...)
+end })
diff --git a/cmus-widget/screenshots/cmus-widget.png b/cmus-widget/screenshots/cmus-widget.png
new file mode 100644
index 0000000..ba04401
--- /dev/null
+++ b/cmus-widget/screenshots/cmus-widget.png
Binary files differ
diff --git a/logout-menu-widget/README.md b/logout-menu-widget/README.md
index d47dcb2..6f8ca27 100644
--- a/logout-menu-widget/README.md
+++ b/logout-menu-widget/README.md
@@ -6,7 +6,7 @@ This widget shows a menu with options to log out from the current session, lock,
## Installation
-Clone this repo (if not cloned yet) **./.config/awesome/**
+Clone this repo (if not cloned yet) under **./.config/awesome/**
```bash
cd ./.config/awesome/
diff --git a/scripts/update_site.sh b/scripts/update_site.sh
new file mode 100755
index 0000000..35fc971
--- /dev/null
+++ b/scripts/update_site.sh
@@ -0,0 +1,14 @@
+mkdir ./_widgets
+for D in *; do
+ if [[ -d "${D}" ]] && [[ ${D} == *"-widget"* ]]; then
+ echo "${D}"
+ cp ${D}/README.md ./_widgets/${D}.md
+ sed -i '1s/^/---\nlayout: page\n---\n/' ./_widgets/${D}.md
+
+ mkdir -p ./assets/img/widgets/screenshots/${D}
+
+ find ${D}/ \( -name '*.jpg' -o -name '*.png' -o -name '*.gif' \) -exec cp '{}' ./assets/img/widgets/screenshots/${D} \;
+
+ sed -i "s/](\.\(\/screenshots\)\{0,1\}/](..\/awesome-wm-widgets\/assets\/img\/widgets\/screenshots\/$D/g" ./_widgets/${D}.md
+ fi
+done
diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua
index 0eb302a..f8df1ea 100644
--- a/spotify-widget/spotify.lua
+++ b/spotify-widget/spotify.lua
@@ -16,6 +16,10 @@ local GET_SPOTIFY_STATUS_CMD = 'sp status'
local GET_CURRENT_SONG_CMD = 'sp current'
local function ellipsize(text, length)
+ -- utf8 only available in Lua 5.3+
+ if utf8 == nil then
+ return text:sub(0, length)
+ end
return (utf8.len(text) > length and length > 0)
and text:sub(0, utf8.offset(text, length - 2) - 1) .. '...'
or text
@@ -154,4 +158,4 @@ end
return setmetatable(spotify_widget, { __call = function(_, ...)
return worker(...)
-end }) \ No newline at end of file
+end })