diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2024-10-05 11:51:10 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2024-10-05 11:51:10 -0500 |
commit | 5a20302dc51bd0cae9562460c8e202bfd604b6ea (patch) | |
tree | 29f0f404eb1d5cfef35d02c92ac2a15474f4f025 /awesome/widgets/pipewire.lua | |
parent | d1f9ee5eced0c273de6c598f88ddb0f7b4e54230 (diff) | |
download | dotconfig-5a20302dc51bd0cae9562460c8e202bfd604b6ea.tar.xz dotconfig-5a20302dc51bd0cae9562460c8e202bfd604b6ea.zip |
pavolctld module and more
Diffstat (limited to 'awesome/widgets/pipewire.lua')
-rw-r--r-- | awesome/widgets/pipewire.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/awesome/widgets/pipewire.lua b/awesome/widgets/pipewire.lua new file mode 100644 index 0000000..3195ee7 --- /dev/null +++ b/awesome/widgets/pipewire.lua @@ -0,0 +1,34 @@ +local awful = require("awful") +local wibox = require("wibox") + +--local get_volume_cmd = "wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/Volume: //;s/0*\\.//'" +--local set_volume_cmd = "wpctl set-volume @DEFAULT_AUDIO_SINK@ %d%%%s" -- will be formatted +local get_volume_cmd = "wpctl get-volume @DEFAULT_AUDIO_SINK@" + +local widget = { + textbox = wibox.widget.textbox() +} + +local updating = false +function update_volume() + if updating then + return + end + awful.spawn.easy_async(get_volume_cmd, function(vol) + updating = true + vol = vol:sub(8) * 100 -- skip `Volume: ` whos len is 8 + widget.textbox:set_text(math.floor(vol)) + updating = false + end) +end + +-- NOTE pulseaudio-utils (pactl) is still required due to the dependence on the +-- `pactl subscribe` command. in the future it would be advantageous to replace +-- this. currently it is (probably) only really possible with dbus. +awful.spawn.with_line_callback("pactl subscribe", { stdout = function(stdout) + --update_volume() +end }) + +update_volume() + +return widget.textbox |