add a bunch of sway stuff

This commit is contained in:
Mark Riedesel 2024-06-12 11:42:25 -05:00
parent e0d58c813d
commit 2ac99db38b
15 changed files with 521 additions and 0 deletions

View file

@ -0,0 +1,25 @@
#!/bin/sh
current_abs=$(brightnessctl get)
current_rel() {
echo "$(brightnessctl get) * 100 / $(brightnessctl max)" | bc
}
max=$(brightnessctl max)
factor=3
brightness_step=$((max * factor / 100 < 1 ? 1 : max * factor / 100))
case $1'' in
'') ;;
'down')
# if current value <= 3% and absolute value != 1, set brightness to absolute 1
if [ "$(current_rel)" -le "$factor" ] && [ "$current_abs" -ge 0 ]; then
brightnessctl --quiet set 1
else
brightnessctl --quiet set "${brightness_step}-"
fi
;;
'up')
brightnessctl --quiet set "${brightness_step}+"
;;
esac
current_rel

View file

@ -0,0 +1,44 @@
#!/usr/bin/env sh
set -x
pgrep wf-recorder
status=$?
countdown() {
notify "Recording in 3 seconds" -t 1000
sleep 1
notify "Recording in 2 seconds" -t 1000
sleep 1
notify "Recording in 1 seconds" -t 1000
sleep 1
}
notify() {
line=$1
shift
notify-send "Recording" "${line}" -i /usr/share/icons/Papirus-Dark/32x32/devices/camera-video.svg $*
}
if [ $status != 0 ]; then
target_path=$(xdg-user-dir SCREENSHOT)
timestamp=$(date +'recording_%Y%m%d-%H%M%S')
notify "Select a region to record" -t 1000
area=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
countdown
(sleep 0.5 && waybar-signal recorder) &
if [ "$1" = "-a" ]; then
file="$target_path/$timestamp.mp4"
wf-recorder --audio -g "$area" --file="$file"
else
file="$target_path/$timestamp.webm"
wf-recorder -g "$area" -c libvpx --codec-param="qmin=0" --codec-param="qmax=25" --codec-param="crf=4" --codec-param="b:v=1M" --file="$file"
fi
waybar-signal recorder && notify "Finished recording ${file}"
else
pkill -x --signal SIGINT wf-recorder
waybar-signal recorder
fi

32
.config/sway/scripts/scale.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/sh
make=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .make')
model=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .model')
name=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .name')
current_screen="$make $model ($name)"
increment=0.1
current_scale() {
swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .scale'
}
next_scale=$(current_scale)
scale() {
[ -x "$(command -v way-displays)" ] && way-displays -s SCALE "$current_screen" $next_scale && way-displays -w || swaymsg output "\"$name\"" scale "$next_scale"
}
case $1'' in
'')
current_scale
;;
'up')
next_scale=$(echo "$(current_scale) + $increment" | bc)
scale
;;
'down')
next_scale=$(echo "$(current_scale) - $increment" | bc)
scale
;;
esac