This commit is contained in:
Nickolaj Jepsen 2024-08-28 16:08:36 +00:00
parent c69ed34507
commit d68c699a7a
18 changed files with 644 additions and 203 deletions

View file

@ -0,0 +1,2 @@
#!/bin/sh
cat /sys/class/power_supply/BAT0/capacity

View file

@ -0,0 +1,2 @@
#!/bin/sh
cat /sys/class/power_supply/BAT0/status

View file

@ -0,0 +1,21 @@
#! /bin/bash
function clamp {
min=$1
max=$2
val=$3
python -c "print(max($min, min($val, $max)))"
}
direction=$1
current=$2
if test "$direction" = "down"
then
target=$(clamp 1 10 $(($current+1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
elif test "$direction" = "up"
then
target=$(clamp 1 10 $(($current-1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
fi

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
hyprctl monitors -j | jq '.[] | select(.focused) | .name'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^focusedmon>>/ {print $2}'

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}'

View file

@ -0,0 +1,3 @@
#!/bin/sh
hyprctl activewindow -j | jq --raw-output .title | sed 's/\(.\{120\}\).*/\1.../'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' | sed 's/\(.\{120\}\).*/\1.../'

View file

@ -0,0 +1,10 @@
#!/bin/bash
spaces (){
hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .}) | from_entries' -Mc
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done

View file

@ -0,0 +1,95 @@
#!/usr/bin/env bash
# FROM HERE: https://github.com/end-4/dots-hyprland/blob/6c09531bc2d168e79b2a76f0174b297a3b66b9b0/.config/eww/scripts/volume
cd ~/.config/eww
volicons=("" "󰖀" "󰕾")
XDG_CACHE_HOME="$HOME/.cache"
lock=0
vol() {
wpctl get-volume @DEFAULT_AUDIO_$1@ | awk '{print int($2*100)}'
}
ismuted() {
wpctl get-volume @DEFAULT_AUDIO_"$1"@ | rg -i muted
echo $?
}
setvol() {
wpctl set-volume @DEFAULT_AUDIO_"$1"@ "$(awk -v n="$2" 'BEGIN{print (n / 100)}')"
}
setmute() {
wpctl set-mute @DEFAULT_AUDIO_"$1"@ toggle
}
if [ "$1" = "--once" ]; then
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
ismuted=$(ismuted "SINK")
if [ "$ismuted" = 1 ]; then
icon="${volicons[$lvl]}"
else
icon="󰝟"
fi
audio=1
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
audio=1
else
audio=0
fi
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
exit 0
fi
if [ "$1" = "mute" ]; then
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
echo "Can only mute SINK or SOURCE"; exit 1
fi
setmute "$2"
elif [ "$1" = "setvol" ]; then
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
echo "Can only set volume for SINK or SOURCE"; exit 1
elif [ "$3" -lt 1 ] || [ "$3" -gt 100 ]; then
echo "Volume must be between 1 and 100"; exit 1
fi
setvol "$2" "$3"
else
# initial values
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
ismuted=$(ismuted "SINK")
if [ "$ismuted" = 1 ]; then
icon="${volicons[$lvl]}"
else
icon="󰝟"
fi
audio=1
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
audio=1
else
audio=0
fi
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
# event loop
pactl subscribe | rg --line-buffered "on sink" | while read -r _; do
lvl=$(awk -v n="$(vol "SINK")" 'BEGIN{print int(n/34)}')
ismuted=$(ismuted "SINK")
if [ "$ismuted" = 1 ]; then
icon="${volicons[$lvl]}"
else
icon="󰝟"
fi
audio=1
if [ "$(wpctl status | grep 'MUTED')" == "" ]; then
audio=1
else
audio=0
fi
echo '{"icon":"'"$icon"'","audio":"'"$audio"'","percent":"'"$(vol "SINK")"'","microphone":"'"$(vol "SOURCE")"'"}'
done
fi