2024-12-03 16:50:23 -05:00
|
|
|
{ pkgs, config, ... }:
|
|
|
|
{
|
|
|
|
home.packages = with pkgs; [
|
2024-12-04 02:54:40 -05:00
|
|
|
(pkgs.writeScriptBin "tools-sway" ''
|
2024-12-03 16:50:23 -05:00
|
|
|
# List the app name and whether or not it uses wayland
|
|
|
|
prop() {
|
|
|
|
selected_window=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)"' | slurp -r -c ${config.look.colors.prime} -B 00000066 -b 00000000)
|
|
|
|
if [ -n "$selected_window" ]; then
|
|
|
|
app_id=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | select("\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)" == "'"$selected_window"'") | .app_id')
|
|
|
|
system=$(sed 's/xdg_shell/Wayland/g; s/xwayland/Xorg/g' < <(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | select("\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)" == "'"$selected_window"'") | .shell'))
|
|
|
|
notify-send "$(echo -e "Window's app_id: $app_id\nWindow System: $system")"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Kill a selected window
|
|
|
|
kill() {
|
|
|
|
selected_window=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)"' | slurp -r -c ${config.look.colors.prime} -B 00000066 -b 00000000)
|
|
|
|
if [ -n "$selected_window" ]; then
|
|
|
|
pid=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | select("\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)" == "'"$selected_window"'") | .pid')
|
|
|
|
kill -9 "$pid"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" == "--prop" ]; then
|
|
|
|
prop
|
|
|
|
elif [ "$1" == "--kill" ]; then
|
|
|
|
kill
|
|
|
|
else
|
|
|
|
echo "Please use the arguments --prop or --kill."
|
|
|
|
fi
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
}
|