2024-10-21 12:31:30 +07:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-06-12 09:54:11 +07:00
|
|
|
let
|
|
|
|
cfg = config.profile.hyprland;
|
2024-10-17 08:47:40 +07:00
|
|
|
inherit (lib.meta) getExe;
|
2024-10-21 12:31:30 +07:00
|
|
|
selectWindowScript =
|
|
|
|
pkgs.writeShellScriptBin ''select-window.sh'' # sh
|
|
|
|
''
|
|
|
|
state="$(hyprctl -j clients)"
|
|
|
|
active_window="$(hyprctl -j activewindow)"
|
|
|
|
|
|
|
|
current_addr="$(echo "$active_window" | gojq -r '.address')"
|
|
|
|
|
|
|
|
window="$(echo "$state" |
|
|
|
|
gojq -r '.[] | select(.monitor != -1 ) | "\(.address) \(.workspace.name) \(.title)"' |
|
|
|
|
grep -v "scratch_term" |
|
|
|
|
sed "s|$current_addr|focused ->|" |
|
|
|
|
sort -r |
|
|
|
|
rofi -dmenu -i -matching fuzzy)"
|
|
|
|
|
|
|
|
addr="$(echo "$window" | awk '{print $1}')"
|
|
|
|
ws="$(echo "$window" | awk '{print $2}')"
|
|
|
|
|
|
|
|
if [[ "$addr" =~ focused* ]]; then
|
|
|
|
echo 'already focused, exiting'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
fullscreen_on_same_ws="$(echo "$state" | gojq -r ".[] | select(.fullscreen == true) | select(.workspace.name == \"$ws\") | .address")"
|
|
|
|
|
|
|
|
if [[ "$window" != "" ]]; then
|
|
|
|
if [[ "$fullscreen_on_same_ws" == "" ]]; then
|
|
|
|
hyprctl dispatch focuswindow address:''${addr}
|
|
|
|
else
|
|
|
|
notify-send 'Complex switch' "$window"
|
|
|
|
hyprctl --batch "dispatch focuswindow address:''${fullscreen_on_same_ws}; dispatch fullscreen 1;"
|
|
|
|
fi
|
2024-10-17 08:47:40 +07:00
|
|
|
fi
|
2024-10-21 12:31:30 +07:00
|
|
|
'';
|
2024-11-19 15:46:13 +07:00
|
|
|
openProjectScript =
|
|
|
|
pkgs.writeShellScriptBin ''select-project.sh'' # sh
|
|
|
|
''
|
|
|
|
dir=$(zoxide query --list | rofi -dmenu -i -matching fuzzy)
|
|
|
|
if [[ "$dir" != "" ]]; then
|
|
|
|
foot --title="Project: $dir" --working-directory="$dir"
|
|
|
|
fi
|
|
|
|
'';
|
2024-06-12 09:54:11 +07:00
|
|
|
in
|
|
|
|
{
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-10-17 08:47:40 +07:00
|
|
|
home.packages = with pkgs; [
|
|
|
|
rofi-wayland
|
|
|
|
gojq
|
2024-06-12 09:54:11 +07:00
|
|
|
];
|
|
|
|
|
|
|
|
home.file.".config/rofi" = {
|
|
|
|
source = ./rofi;
|
|
|
|
recursive = true;
|
|
|
|
};
|
2024-10-16 21:14:36 +07:00
|
|
|
|
|
|
|
wayland.windowManager.hyprland.settings.bind = [
|
|
|
|
"$mod, D, exec, rofi -show drun -replace -i"
|
2024-10-17 08:47:40 +07:00
|
|
|
"$mod, F, exec, ${getExe selectWindowScript}"
|
2024-11-19 15:46:13 +07:00
|
|
|
"$mod, P, exec, ${getExe openProjectScript}"
|
2024-10-16 21:14:36 +07:00
|
|
|
];
|
2024-06-12 09:54:11 +07:00
|
|
|
};
|
|
|
|
}
|