mirror of
https://github.com/Ahwxorg/nixos-config.git
synced 2025-12-04 06:50:14 +01:00
feat: adds back walp script that was used years ago
This commit is contained in:
parent
2839967c55
commit
2bc69bf6e4
1 changed files with 28 additions and 121 deletions
|
|
@ -1,130 +1,37 @@
|
||||||
{ pkgs, username, ... }:
|
{ username, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
home.file = {
|
home.file = {
|
||||||
"/home/${username}/.local/bin/hyprland-smart-borders" = {
|
"/home/${username}/.config/sxiv/exec/key-handler" = {
|
||||||
executable = true;
|
executable = true;
|
||||||
text = ''
|
text = ''
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
function handle {
|
while read file
|
||||||
if [[ ''${1:0:10} == "openwindow" ]]
|
do
|
||||||
then
|
case "$1" in
|
||||||
window_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=1)
|
"w") setbg "$file" ;;
|
||||||
workspace_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=2)
|
"d") mv "$file" "$HOME/.trash/";;
|
||||||
if [[ $workspace_id == "special" ]]
|
esac
|
||||||
then
|
done
|
||||||
workspace_id=-99
|
'';
|
||||||
fi
|
};
|
||||||
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
|
"/home/${username}/.local/bin/setbg" = {
|
||||||
|
executable = true;
|
||||||
if [[ $windows -eq 1 ]]
|
text = ''
|
||||||
then
|
#!/bin/sh
|
||||||
floating_status=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$window_id\" ) | .floating" )
|
|
||||||
if [[ $floating_status == "false" ]]
|
convert "$1" ~/.local/share/bg.png
|
||||||
then
|
swww img ~/.local/share/bg.png --transition-type fade
|
||||||
hyprctl setprop address:0x$window_id forcenoborder 1 lock
|
'';
|
||||||
else
|
};
|
||||||
hyprctl setprop address:0x$window_id forcenoborder 0 lock
|
"/home/${username}/.local/bin/walp" = {
|
||||||
return
|
executable = true;
|
||||||
fi
|
text = ''
|
||||||
|
#!/bin/sh
|
||||||
elif [[ $windows -eq 2 ]]
|
|
||||||
then
|
which swiv &>/dev/null && SIV=swiv || SIV=nsxiv # todo: switch to swiv, but that is not packaged for Nix yet.
|
||||||
addresses=$(hyprctl clients -j | jq -r --arg foo "$foo" ".[] | select(.workspace.id == $workspace_id) | .address")
|
$SIV -t ~/Pictures/wallpapers/other/*
|
||||||
for address in $addresses
|
|
||||||
do
|
|
||||||
if [[ "$address" != "$window_id" ]]; then
|
|
||||||
hyprctl setprop address:$(echo $address | xargs) forcenoborder 0 lock
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [[ ''${1:0:10} == "movewindow" ]]
|
|
||||||
then
|
|
||||||
window_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=1)
|
|
||||||
workspace_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=2)
|
|
||||||
|
|
||||||
# Sepcial workspaces have an id of -99, they need to be handled separately
|
|
||||||
if [[ $workspace_id == "special" ]]
|
|
||||||
then
|
|
||||||
workspace_id=-99
|
|
||||||
fi
|
|
||||||
|
|
||||||
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
|
|
||||||
|
|
||||||
if [[ $windows -eq 1 ]]
|
|
||||||
then
|
|
||||||
# Check if the current window is floating and then set the border accordingly
|
|
||||||
floating_status=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$window_id\" ) | .floating" )
|
|
||||||
if [[ $floating_status == "false" ]]
|
|
||||||
then
|
|
||||||
hyprctl setprop address:0x$window_id forcenoborder 1 lock
|
|
||||||
else
|
|
||||||
hyprctl setprop address:0x$window_id forcenoborder 0 lock
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
elif [[ $windows -eq 2 ]]
|
|
||||||
then
|
|
||||||
addresses=$(hyprctl clients -j | jq -r --arg foo "$foo" ".[] | select(.workspace.id == $workspace_id) | .address")
|
|
||||||
for address in $addresses
|
|
||||||
do
|
|
||||||
if [[ "$address" != "$window_id" ]]; then
|
|
||||||
hyprctl setprop address:$(echo $address | xargs) forcenoborder 0 lock
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Handle all the other workspaces with only one window
|
|
||||||
single_window_workspaces=$(hyprctl workspaces -j | jq '.[] | select(.windows == 1)' | jq ".id")
|
|
||||||
for workspace in $single_window_workspaces
|
|
||||||
do
|
|
||||||
window=$(hyprctl clients -j | jq ".[] | select(.workspace.id == $workspace) | .address")
|
|
||||||
hyprctl setprop address:$(echo $window | xargs) forcenoborder 1 lock
|
|
||||||
done
|
|
||||||
|
|
||||||
elif [[ ''${1:0:11} == "closewindow" ]]
|
|
||||||
then
|
|
||||||
workspace_id=$(hyprctl activewindow -j | jq ".workspace.id")
|
|
||||||
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
|
|
||||||
|
|
||||||
if [[ $windows -eq 1 ]]
|
|
||||||
then
|
|
||||||
window_id=$(hyprctl activewindow -j | jq -r ".address")
|
|
||||||
floating_status=$(hyprctl activewindow -j | jq ".floating")
|
|
||||||
if [[ $floating_status == "false" ]]
|
|
||||||
then
|
|
||||||
hyprctl setprop address:$window_id forcenoborder 1 lock
|
|
||||||
else
|
|
||||||
hyprctl setprop address:$window_id forcenoborder 0 lock
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [[ ''${1:0:18} == "changefloatingmode" ]]
|
|
||||||
then
|
|
||||||
floating_status=$(echo $1 | cut --delimiter ">" --fields 3 | cut --delimiter "," --fields 2)
|
|
||||||
address="0x$(echo $1 | cut --delimiter ">" --fields 3 | cut --delimiter "," --fields 1)"
|
|
||||||
workspace_id=$(hyprctl clients -j | jq --arg address "$address" '.[] | select(.address == $address) | .workspace.id')
|
|
||||||
if [[ $floating_status -eq 1 ]]
|
|
||||||
then
|
|
||||||
hyprctl setprop address:$address forcenoborder 0 lock
|
|
||||||
else
|
|
||||||
no_windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
|
|
||||||
if [[ $no_windows -eq 1 ]]
|
|
||||||
then
|
|
||||||
hyprctl setprop address:$address forcenoborder 1 lock
|
|
||||||
else
|
|
||||||
hyprctl setprop address:$address forcenoborder 0 lock
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Socket directory has changed in Hyprland v0.40.0
|
|
||||||
# socat - UNIX-CONNECT:/tmp/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done
|
|
||||||
socat - UNIX-CONNECT:$(echo $XDG_RUNTIME_DIR)/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue