feat(eww): add mediaplayer widget, fix workspaces, window and audio widgets

This commit is contained in:
João Dias
2024-11-24 11:14:12 -03:00
parent 88af8f4a37
commit f7ae531efd
11 changed files with 115 additions and 71 deletions
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env
handle() {
case $1 in
workspace*) hyprctl -j activeworkspace | jq -c ;;
esac
}
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env bash
WP_VOLUME=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed -e 's/^Volume: //')
formatted_volume() {
if ! [ $WP_VOLUME == "1.00" ]; then
echo "${WP_VOLUME#0.}%"
else
echo "100%"
fi
}
formatted_volume
-37
View File
@@ -1,37 +0,0 @@
#!/usr/bin/env bash
ACTIVE_WINDOW=$(hyprctl -j activewindow)
WINDOW_TITLE=$(echo $ACTIVE_WINDOW | jq '.title' | sed -e 's/^\"//' -e 's/\"$//')
WINDOW_CLASS=$(echo $ACTIVE_WINDOW | jq '.class' | sed -e 's/^\"//' -e 's/\"$//')
WINDOW_NAME="$WINDOW_CLASS: $WINDOW_TITLE"
WINDOW_CHAR_LIMIT="50"
# Rewrite window names
case $WINDOW_CLASS in
"zen-alpha")
WINDOW_NAME="Zen Browser"
;;
"firefox" | "org.mozilla.firefox")
WINDOW_NAME="Mozilla Firefox"
;;
esac
#case $WINDOW_TITLE in
# "example with window title") # case
# WINDOW_NAME="you just learned!" # statement
# ;; # breaks
#esac
#case $WINDOW_NAME in
# "example with window name") # case
# WINDOW_NAME="something cool" # statement
# ;; # breaks
#esac
if ! [[ $WINDOW_CLASS == "null" ]]; then
echo "${WINDOW_NAME:0:WINDOW_CHAR_LIMIT}"
eww update widget_window_visible=true
else
echo ""
eww update widget_window_visible=false
fi
+14 -4
View File
@@ -2,17 +2,27 @@
# Note: $SCROLL is defined by eww
$DEFAULT_INCREASE='5'
DEFAULT_INCREASE='5'
Guess_increase_decrease() {
local $CURRENT_VOL=$(wpctl get-volume "@DEFAULT_AUDIO_SINK@")
CURRENT_VOL=$(Translate_volume_to_int)
if [[ $SCROLL == "up" ]]; then
if [[ $(awk "BEGIN { ($CURRENT_VOL+$DEFAULT_INCREASE) }") > 100 ]]; then
echo "1.00"
else
echo "$DEFAULT_INCREASE%+"
fi
else
echo "$DEFAULT_INCREASE%-"
fi
}
Update_volume() {
local $UPDATED_VOL=$(Guess_increase_decrease)
UPDATED_VOL=$(Guess_increase_decrease)
wpctl set-volume "@DEFAULT_AUDIO_SINK@" "$UPDATED_VOL"
}
Translate_volume_to_int() {
echo $(wpctl get-volume "@DEFAULT_AUDIO_SINK@" | sed -e "s/^Volume: //" -e "s/^1.//1")
echo $(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed -e 's/Volume: //' -e 's/^1\./1/' -e 's/^0.//' -e 's/^00/0/')
}
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# output current window before event trigger to prevent issues
hyprctl -j activewindow | jq -c
handle() {
case $1 in
activewindow*) hyprctl -j activewindow | jq -c ;;
esac
}
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# display workspaces before checking for events
hyprctl -j workspaces | jq -c
handle() {
case $1 in
workspace*) hyprctl -j workspaces | jq -c ;;
esac
}
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done