Add hyprstack config

This commit is contained in:
2024-07-06 12:59:14 +03:00
parent ead8c1df03
commit b820d657ee
32 changed files with 1417 additions and 0 deletions
@@ -0,0 +1,7 @@
(deflisten window :initial "..." "sh ./widgets/active-window/get-active-window.sh")
(defwidget active-window []
(box
(label :class "box" :text "${window}")
)
)
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
hyprctl activewindow -j | jq --raw-output .title
socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}'
+24
View File
@@ -0,0 +1,24 @@
(defpoll volume-level :interval "1s" "sh widgets/audio/get-volume-level.sh")
(defwidget icon []
(label :text {volume-level > 66 ? "" : volume-level > 0 ? "" : ""})
)
; TODO figure out the sink IDs dynamically?
(defwidget audio []
(box
:orientation "h"
:space-evenly false
:halign "end"
(eventbox :cursor "pointer" (button :class "audio-source interactive" :onclick "pactl set-default-sink 57" "󰍹"))
(eventbox :cursor "pointer" (button :class "audio-source-2 interactive" :onclick "pactl set-default-sink 64" "󰋋"))
(eventbox :cursor "pointer" :class "interactive" :onscroll "sh widgets/audio/change-volume.sh {}"
(box :class "volume"
(icon)
(button :onclick "pavucontrol &"
(label :text "${volume-level}%")
)
))
)
)
@@ -0,0 +1,9 @@
#!/usr/bin/env sh
if [[ $1 == "up" ]]; then
wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
elif [[ $1 == "down" ]]; then
wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
else
wpctl set-volume @DEFAULT_AUDIO_SINK@ $1
fi
@@ -0,0 +1,21 @@
#!/usr/bin/env sh
volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
#todo fix 100% case
volume_value=$(echo $volume | cut -d':' -f2)
if [ $volume_value == "0.00" ]; then
echo "0"
exit 0
fi
if [[ $volume_value =~ ^" 1" ]]; then
echo "${volume_value//.}"
exit 0
fi
volume_percent=$(echo $volume_value | cut -d'.' -f2)
echo $volume_percent
@@ -0,0 +1,9 @@
; this is taking up too much CPU time
(defpoll brightness-1 :interval "2s" "ddcutil -d 1 getvcp 10 | awk '{ split($9, a, \",\"); print a[1]}'")
(defwidget brightness []
(eventbox :onscroll "sh widgets/brightness/change-brightness.sh {} ${brightness-1 + 0}"
(label :text "󰃞 ${substring(brightness-1, 0, 2)}")
)
)
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
case $1 in
up)
ddcutil -d 1 setvcp 10 $(($2 + 10))
;;
down)
ddcutil -d 1 setvcp 10 $(($2 - 10))
;;
esac
+10
View File
@@ -0,0 +1,10 @@
(defwidget clock []
(box :class "clock"
:orientation "h"
:space-evenly false
:halign "center"
date-time)
)
(defpoll date-time :interval "1s"
"sh widgets/clock/date-time.sh")
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
DaySuffix() {
case `date +%-d` in
1|21|31) echo "st";;
2|22) echo "nd";;
3|23) echo "rd";;
*) echo "th";;
esac
}
date=$(date "+%a, %b %-d`DaySuffix` · %H:%M")
printf "%s" "$date"
@@ -0,0 +1,12 @@
(defwidget kbd-layout []
(box
:orientation "h"
:space-evenly false
:halign "center"
(eventbox :cursor "pointer" :class "interactive" :onclick "hyprctl switchxkblayout usb-hid-keyboard next"
(label :text {keyboard-layout} :class "kbd-layout")
)
)
)
(deflisten keyboard-layout :initial "en" "python ./lib/get-kb-layout.py")
+50
View File
@@ -0,0 +1,50 @@
(defpoll media-status :interval "1s" "playerctl status")
(defpoll media-artist :interval "1s" "playerctl metadata --format \"{{artist}}\"")
(defpoll media-title :interval "1s" "playerctl metadata --format \"{{title}}\"")
(defpoll media-album :interval "1s" "playerctl metadata --format \"{{album}}\"")
(defpoll media-artUrl :interval "1s" "playerctl metadata --format \"{{mpris:artUrl}}\"")
(defpoll media-length :interval "1s" "playerctl metadata --format \"{{duration(mpris:length)}}\"")
(defwidget media []
(box
(eventbox :cursor "pointer" :onclick "eww open --toggle window_media" :class "interactive" :onmiddleclick "playerctl play-pause"
(box :class "media-status"
(label :text "${media-status == "Playing" ? "" : media-status == "Paused" ? "" : ""}")
)
)
)
)
(defwidget media_full []
(box :orientation "v" :space-evenly false :class "media-window"
(label :text media-artist :show-truncated false)
(label :text media-title :show-truncated false)
(label :text media-album :show-truncated false)
(box :class "media-cover" :style "background: url('${media-artUrl}')" :width 180 :height 140)
(box :class "media-controls" :spacing 16
(eventbox :cursor "pointer" :onclick "playerctl previous" :class "media-button" "")
(eventbox :cursor "pointer" :class "media-button play" :onclick "playerctl play" "")
(eventbox :cursor "pointer" :class "media-button pause" :onclick "playerctl pause" "")
(eventbox :cursor "pointer" :class "media-button next" :onclick "playerctl next" "")
)
)
)
(defwindow window_media
:monitor 0
:geometry (geometry :x "8px"
:y "8px"
:width "300px"
:anchor "top right"
)
:wm-ignore false
:focusable false
(box :class "control-centre bar"
(media_full)
)
)
@@ -0,0 +1,17 @@
#!/usr/bin/env sh
direction=$1
current=$2
if [[ $direction == "down" ]]; then
target=$(($current+1))
if [[ $target == 11 ]]; then
exit 0
fi
hyprctl dispatch workspace $target
elif [[ $direction == "up" ]]; then
target=$(($current-1))
hyprctl dispatch workspace $target
else
target=$1
hyprctl dispatch workspace $target
fi
@@ -0,0 +1,6 @@
##!/usr/bin/env sh
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}'
@@ -0,0 +1,46 @@
#!/usr/bin/env sh
## NOTE: This file is unused currently
NUMBER_OF_WORKSPACES=6
window_class() {
echo `hyprctl activewindow -j | jq --raw-output .class`
}
window_title() {
echo `hyprctl activewindow -j | jq --raw-output .title`
}
workspaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 $NUMBER_OF_WORKSPACES | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
if [[ $1 == 'workspaces' ]]; then
echo "{ \"workspaces\": $(workspaces), \"active\": 1, \"active_empty\": true }"
socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
active=$(eww get workspaces | jq .active)
if [[ ${line:0:9} == 'workspace' ]]; then
active=${line:11:2}
fi
active_empty='true'
let "i = $active - 1"
if [[ $(workspaces | jq --raw-output .[$i].windows) -gt 0 ]]; then active_empty='false'; fi
eww update workspaces="{
\"workspaces\": $(workspaces),
\"active\": $active,
\"active_empty\": $active_empty
}"
eww update dock_reveal="$active_empty"
done
fi
if [[ $1 == 'window' ]]; then
window_class
socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
window_class
done
fi
@@ -0,0 +1,13 @@
(deflisten active-workspace :initial "." "sh widgets/workspaces/get-active-workspace.sh")
(defwidget workspaces [?monitor-workspaces]
(box :class "workspaces"
:orientation "h"
:space-evenly true
:halign "start"
:spacing 10
(for workspace in monitor-workspaces
(button :class "workspace ${active-workspace == workspace ? "current" : ""}" :onclick "hyprctl dispatch workspace ${workspace}" "${workspace}")
)
)
)