[*] Multiple new configs
This commit is contained in:
4
scripts/scripts/assets/audio-speakers-symbolic.svg
Normal file
4
scripts/scripts/assets/audio-speakers-symbolic.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m 12.039062 0.00390625 c -0.257812 -0.01171875 -0.523437 0.07421875 -0.726562 0.28124975 l -3.3125 3.292969 v 1.421875 h 1.390625 l 3.304687 -3.300781 c 0.40625 -0.402344 0.359376 -1.039063 0.03125 -1.390625 c -0.175781 -0.183594 -0.429687 -0.292969 -0.6875 -0.30468775 z m -5.039062 1.00390575 c -0.296875 -0.003906 -0.578125 0.125 -0.769531 0.351563 l -3.230469 3.640625 h -1 c -1.09375 0 -2 0.84375 -2 2 v 2 c 0 1.089844 0.910156 2 2 2 h 1 l 3.230469 3.640625 c 0.210937 0.253906 0.492187 0.363281 0.769531 0.359375 z m 1 5.992188 v 2 h 6 c 0.75 0 1 -0.5 1 -1 s -0.25 -1 -1 -1 z m 0 4 v 1.421875 l 3.324219 3.292969 c 0.402343 0.410156 1.0625 0.347656 1.414062 -0.023438 c 0.328125 -0.351562 0.371094 -0.988281 -0.03125 -1.390625 l -3.316406 -3.300781 z m 0 0" fill="#aaaaaa"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 928 B |
4
scripts/scripts/assets/video-display-symbolic.svg
Normal file
4
scripts/scripts/assets/video-display-symbolic.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m 3 0 c -1.660156 0 -3 1.339844 -3 3 v 7 c 0 1.660156 1.339844 3 3 3 h 10 c 1.660156 0 3 -1.339844 3 -3 v -7 c 0 -1.660156 -1.339844 -3 -3 -3 z m 0 2 h 10 c 0.554688 0 1 0.445312 1 1 v 7 c 0 0.554688 -0.445312 1 -1 1 h -10 c -0.554688 0 -1 -0.445312 -1 -1 v -7 c 0 -0.554688 0.445312 -1 1 -1 z m 2 12 c -1.105469 0 -2 0.894531 -2 2 h 10 c 0 -1.105469 -0.894531 -2 -2 -2 z m 0 0" fill="#aaaaaa"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 543 B |
2002
scripts/scripts/hs_audio.sh
Executable file
2002
scripts/scripts/hs_audio.sh
Executable file
File diff suppressed because it is too large
Load Diff
75
scripts/scripts/notify_utils.sh
Normal file
75
scripts/scripts/notify_utils.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
parent_dir="$(dirname $0)"
|
||||
assets_dir="$parent_dir/assets"
|
||||
|
||||
brightness_icon=$assets_dir/video-display-symbolic.svg
|
||||
volume_icon=$assets_dir/audio-speakers-symbolic.svg
|
||||
default_playback_icon=$assets_dir/audio-speakers-symbolic.svg
|
||||
# Create cache dir once
|
||||
: "${TMP_CACHE_DIR:=/tmp/bash_url_cache}"
|
||||
mkdir -p "$TMP_CACHE_DIR"
|
||||
|
||||
get_local_path() {
|
||||
local input="$1"
|
||||
|
||||
# Check if it's an HTTP/HTTPS URL
|
||||
if [[ "$input" =~ ^https?:// ]]; then
|
||||
# Create a stable filename from the URL (hash)
|
||||
local hash
|
||||
hash=$(printf '%s' "$input" | sha256sum | awk '{print $1}')
|
||||
|
||||
local cached_file="$TMP_CACHE_DIR/$hash"
|
||||
|
||||
# If already cached, return it
|
||||
if [[ -f "$cached_file" ]]; then
|
||||
echo "$cached_file"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Otherwise download
|
||||
if ! curl -fsSL "$input" -o "$cached_file"; then
|
||||
echo "Error: failed to download $input" >&2
|
||||
rm -f "$cached_file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$cached_file"
|
||||
else
|
||||
# Return original path
|
||||
echo "$input"
|
||||
fi
|
||||
}
|
||||
get_playbackart() {
|
||||
artUrl="$(playerctl metadata mpris:artUrl)"
|
||||
|
||||
if [ -z "$artUrl" ]; then
|
||||
artUrl=$default_playback_icon
|
||||
fi
|
||||
|
||||
echo "$(get_local_path $artUrl)"
|
||||
}
|
||||
|
||||
notify_brightness() {
|
||||
dunstify --app-name=progress --icon=$brightness_icon -h "int:value:$(light -G)" "Brightness"
|
||||
}
|
||||
notify_volume() {
|
||||
dunstify --app-name=progress --icon=$volume_icon -h "int:value:$(pamixer --get-volume)" "Volume"
|
||||
}
|
||||
notify_playback() {
|
||||
dunstify --app-name=playback --replace-id=123456 "$(playerctl metadata xesam:title)" "$(playerctl metadata xesam:artist)" --icon=$(get_playbackart)
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'brightness')
|
||||
notify_brightness
|
||||
;;
|
||||
'volume')
|
||||
notify_volume
|
||||
;;
|
||||
'playback')
|
||||
notify_playback
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
10
scripts/scripts/playerctl_listener.sh
Executable file
10
scripts/scripts/playerctl_listener.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
parent_dir="$(dirname $0)"
|
||||
source "$parent_dir/notify_utils.sh"
|
||||
|
||||
playerctl -F metadata -f "{{xesam:title}} {{mpris:artUrl}}" | while read -s metadata; do
|
||||
if [ -n "$metadata" ]; then
|
||||
notify_playback
|
||||
fi
|
||||
done
|
||||
80
scripts/scripts/util.sh
Normal file
80
scripts/scripts/util.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
# vol_u Increase volume
|
||||
# vol_d Decrease volume
|
||||
# vol_m Toggle mute
|
||||
# br_u Increase display brightness
|
||||
# br_d Decrease display brightness
|
||||
# play-pause Toggle play-pause (through playerctl)
|
||||
# next Next track (through playerctl)
|
||||
# prev Previous track (through playerctl)
|
||||
|
||||
parent_dir="$(dirname $0)"
|
||||
source "$parent_dir/notify_utils.sh"
|
||||
|
||||
volume_increment=5
|
||||
brightness_increment=5
|
||||
|
||||
volume_up() {
|
||||
pamixer -i $volume_increment
|
||||
}
|
||||
volume_down() {
|
||||
pamixer -d $volume_increment
|
||||
}
|
||||
volume_mute() {
|
||||
pamixer -t
|
||||
}
|
||||
|
||||
brightness_up() {
|
||||
light -A $brightness_increment
|
||||
}
|
||||
brightness_down() {
|
||||
light -U $brightness_increment
|
||||
}
|
||||
|
||||
playback_toggle() {
|
||||
playerctl play-pause
|
||||
}
|
||||
playback_next() {
|
||||
playerctl next
|
||||
}
|
||||
playback_prev() {
|
||||
playerctl previous
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'vol_u')
|
||||
volume_up
|
||||
notify_volume
|
||||
;;
|
||||
'vol_d')
|
||||
volume_down
|
||||
notify_volume
|
||||
;;
|
||||
'vol_m')
|
||||
volume_mute
|
||||
notify_volume
|
||||
;;
|
||||
'br_u')
|
||||
brightness_up
|
||||
notify_brightness
|
||||
;;
|
||||
'br_d')
|
||||
brightness_down
|
||||
notify_brightness
|
||||
;;
|
||||
'play-pause')
|
||||
playback_toggle
|
||||
notify_playback
|
||||
;;
|
||||
'next')
|
||||
playback_next
|
||||
notify_playback
|
||||
;;
|
||||
'prev')
|
||||
playback_prev
|
||||
notify_playback
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user