Add Hyprland, attempt generalization
This commit is contained in:
parent
590430f296
commit
a0cc623c4b
57 changed files with 634 additions and 385 deletions
|
@ -1,8 +1,7 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./screen-sway
|
||||
./prop-sway
|
||||
./sleep-sway
|
||||
./tools-sway
|
||||
];
|
||||
}
|
||||
|
|
13
modules/home/wms/sway/programs/prop-sway/default.nix
Normal file
13
modules/home/wms/sway/programs/prop-sway/default.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ pkgs, config, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(pkgs.writeScriptBin "prop-sway" ''
|
||||
selected_window=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)"' | ${pkgs.slurp}/bin/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
|
||||
'')
|
||||
];
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
{ pkgs, config, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(pkgs.writeScriptBin "screen-sway" ''
|
||||
swappy() {
|
||||
# Create an imv window to act as a static screen
|
||||
grim -t jpeg -q 90 - | imv -w "GlobalShot" - & imv_pid=$!
|
||||
|
||||
# Capture the screenshot of the selected area and save to a temporary file
|
||||
selected_area=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"'\
|
||||
| XCURSOR_SIZE=40 slurp -w ${config.look.border.string} -c ${config.look.colors.prime} -B 00000066 -b 00000099)
|
||||
temp_file=$(mktemp -u).png
|
||||
grim -g "$selected_area" "$temp_file"
|
||||
kill $imv_pid
|
||||
|
||||
# Copy the screenshot to the clipboard and clear the temp
|
||||
${pkgs.swappy}/bin/swappy -f - < "$temp_file"
|
||||
rm "$temp_file"
|
||||
}
|
||||
|
||||
screen() {
|
||||
temp_file=$(mktemp -u).png
|
||||
grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') "$temp_file"
|
||||
|
||||
# Check if the screenshot was successfully taken
|
||||
if [ $? -eq 0 ]; then
|
||||
wl-copy < "$temp_file"
|
||||
notify-send -i "$temp_file" "Current screen copied."
|
||||
rm "$temp_file"
|
||||
else
|
||||
notify-send "Error: Unable to capture screenshot."
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" == "--swappy" ]; then
|
||||
swappy
|
||||
elif [ "$1" == "--screen" ]; then
|
||||
screen
|
||||
else
|
||||
echo "Please use the arguments --swappy or --screen."
|
||||
fi
|
||||
'')
|
||||
];
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
{ pkgs, config, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(pkgs.writeScriptBin "tools-sway" ''
|
||||
# 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
|
||||
'')
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue