Signed-off-by: Rainer Bendig <hexathos@mailbox.org>
This commit is contained in:
2020-02-25 23:55:12 +01:00
parent 5ba5cf9f2b
commit 9b3266a32e
33 changed files with 1551 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

View File

@@ -0,0 +1,52 @@
#!/bin/bash
# Copyright 2015 Alexander Tsepkov
#SINK_NAME="alsa_output.pci-0000_00_1b.0.analog-stereo"
#SINK_NAME="alsa_output.pci-0000_00_1b.0.hdmi-stereo"
SOUND_DEVICE=`pacmd dump | grep -P "^set-card-profile" | grep stereo | cut -d: -f2 | cut -d+ -f1`
SINK_NAME="alsa_output.pci-0000_00_1b.0.$SOUND_DEVICE"
VOL_STEP="0x01000"
MUTE_STATE=`pacmd dump | grep -P "^set-sink-mute $SINK_NAME\s+" | perl -p -i -e 's/.+\s(yes|no)$/$1/'`
VOL_NOW=`pacmd dump | grep -P "^set-sink-volume $SINK_NAME\s+" | perl -p -i -e 's/.+\s(.x.+)$/$1/'`
VOL_MAX=$((0x10000))
case "$1" in
plus)
if [ $MUTE_STATE = yes ]; then
echo "Muted"
else
VOL_NEW=$((VOL_NOW + VOL_STEP))
if [ $VOL_NEW -gt $VOL_MAX ]
then
VOL_NEW=$VOL_MAX
fi
pactl set-sink-volume $SINK_NAME `printf "0x%X" $VOL_NEW`
echo "$((100*VOL_NEW / VOL_MAX))%"
fi
;;
minus)
if [ $MUTE_STATE = yes ]; then
echo "Muted"
else
VOL_NEW=$((VOL_NOW - VOL_STEP))
if [ $(($VOL_NEW)) -lt $((0x00000)) ]
then
VOL_NEW=$((0x00000))
fi
pactl set-sink-volume $SINK_NAME `printf "0x%X" $VOL_NEW`
echo "$((100*VOL_NEW / VOL_MAX))%"
fi
;;
mute)
if [ $MUTE_STATE = no ]; then
pactl set-sink-mute $SINK_NAME 1
echo "Muted"
elif [ $MUTE_STATE = yes ]; then
pactl set-sink-mute $SINK_NAME 0
echo "$((100*VOL_NOW / VOL_MAX))%"
fi
esac

View File

@@ -0,0 +1,52 @@
-- Alexander Tsepkov, 2015
--
-- Minimalistic Volume Widget that works with multiple output sources
-- dependency: FontAwesome
local wibox = require("wibox")
local naughty = require("naughty")
local last_id
local vol_muted
function mixercommand(command)
local fd = io.popen(os.getenv("HOME") .. "/.config/awesome/pa-vol.sh " .. command)
local status = fd:read("*all")
fd:close()
local pic = os.getenv("HOME") .. "/.config/awesome/widgets/volume/"
local value
if status == "Muted\n" then
pic = pic .. "audio-muted.png"
else
-- dividing by 26 is a little cheat to prevent overflow on 100%
value = math.floor(tonumber(string.sub(status:gsub("%s+$", ""), 0, -2)) / 26)
pic = pic .. "audio-" .. value .. ".png"
end
last_id = naughty.notify({
title = "Volume",
text = status,
replaces_id = last_id,
icon = pic,
}).id
end
function volumeup()
mixercommand("plus")
end
function volumedown()
mixercommand("minus")
end
function volumetoggle()
mixercommand("mute")
end
-- zenstate not applicable bescause there is no volume icon for this widget at all
-- this widget doesn't have an icon, I use volumeicon instead but I prefer the messages/control through this
-- widget instead
widget = {
up = volumeup,
down = volumedown,
toggle = volumetoggle,
}