switch to getExe and getExe' in hyprland config

This commit is contained in:
jacekpoz 2024-07-05 00:05:03 +02:00
parent fc15c4c9be
commit dee4671179
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -9,7 +9,7 @@
inherit (config.myOptions.other.system) username;
hmCfg = config.home-manager.users.${username};
inherit (lib) elem mkEnableOption mkIf mkOption optionals;
inherit (lib) elem getExe getExe' mkEnableOption mkIf mkOption optionals;
inherit (lib.types) bool listOf nullOr package path str submodule;
inherit (lib.strings) removeSuffix;
inherit (lib.attrsets) mapAttrsToList;
@ -18,13 +18,50 @@
smwPresent = elem inputs.split-monitor-workspaces.packages.${pkgs.system}.split-monitor-workspaces cfg.extraPlugins;
inherit (inputs.nixpkgs-wayland.packages.${pkgs.system}) foot wl-clipboard swww wlsunset;
inherit (inputs.anyrun.packages.${pkgs.system}) anyrun;
foot' = inputs.nixpkgs-wayland.packages.${pkgs.system}.foot;
foot = getExe' foot' "foot";
footclient = getExe' foot' "footclient";
inherit (inputs.nixpkgs-wayland.packages.${pkgs.system}) wl-clipboard;
wl-copy = getExe' wl-clipboard "wl-copy";
wl-paste = getExe' wl-clipboard "wl-paste";
swww = getExe inputs.nixpkgs-wayland.packages.${pkgs.system}.swww;
wlsunset = getExe inputs.nixpkgs-wayland.packages.${pkgs.system}.wlsunset;
anyrun = getExe inputs.anyrun.packages.${pkgs.system}.anyrun;
hyprcontrib = inputs.hyprcontrib.packages.${pkgs.system};
inherit (inputs.shadower.packages.${pkgs.system}) shadower;
grimblast = getExe hyprcontrib.grimblast;
shadower = getExe inputs.shadower.packages.${pkgs.system}.shadower;
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland xdg-desktop-portal-hyprland;
inherit (inputs.waybar.packages.${pkgs.system}) waybar;
woomer = inputs.woomer.packages.${pkgs.system}.default;
hyprctl = getExe' hyprland "hyprctl";
waybar = getExe inputs.waybar.packages.${pkgs.system}.waybar;
woomer = getExe inputs.woomer.packages.${pkgs.system}.default;
pkill = getExe' pkgs.procps "pkill";
tee = getExe' pkgs.coreutils-full "tee";
xdg-user-dir = getExe' pkgs.xdg-user-dirs "xdg-user-dir";
xdg-open = getExe' pkgs.xdg-utils "xdg-open";
notify-send = getExe pkgs.libnotify;
swappy = getExe pkgs.swappy;
asusctl = getExe' config.services.asusd.package "asusctl";
rog-control-center = getExe' config.services.asusd.package "rog-control-center";
systemctl = getExe' pkgs.systemd "systemctl";
loginctl = getExe' pkgs.systemd "loginctl";
dbus-update-activation-environment = getExe' pkgs.dbus "dbus-update-activation-environment";
btop = getExe pkgs.btop;
amdgpu_top = getExe pkgs.amdgpu_top;
helvum = getExe pkgs.helvum;
pwvucontrol = getExe pkgs.pwvucontrol;
nm-applet = getExe pkgs.networkmanagerapplet;
blueman-applet = getExe' pkgs.blueman "blueman-applet";
keepassxc = getExe' pkgs.keepassxc "keepassxc";
playerctl = getExe pkgs.playerctl;
pamixer = getExe pkgs.pamixer;
brightnessctl = getExe pkgs.brightnessctl;
rg = getExe pkgs.ripgrep;
gawk = getExe pkgs.gawk;
mpv = getExe pkgs.mpv;
in {
options.myOptions.programs.hypr.land = {
enable = mkEnableOption "hiper ląd";
@ -123,7 +160,7 @@ in {
extraConfig = ''
bind=$mainMod, W, exec, ${removeSuffix " %U" hmCfg.xdg.desktopEntries.firefox-schizo.exec}
bind=$mainMod SHIFT, W, exec, ${removeSuffix " %U" hmCfg.xdg.desktopEntries.firefox-unschizo.exec}
${if (cfg.startupSound != null) then "exec-once=${pkgs.mpv}/bin/mpv --no-video --volume=100 ${hmCfg.xdg.dataHome}/hypr/startup_sound" else ""}
${if (cfg.startupSound != null) then "exec-once=${mpv} --no-video --volume=100 ${hmCfg.xdg.dataHome}/hypr/startup_sound" else ""}
'';
settings = {
"$mainMod" = "SUPER";
@ -159,12 +196,10 @@ in {
# scratchpads
"special:btop, decorate:false"
(mkIf isAmdGpuPresent
"special:amdgpu_top, decorate:false")
(mkIf isAmdGpuPresent "special:amdgpu_top, decorate:false")
"special:pipewire, decorate:false"
"special:nixos, decorate:false"
(mkIf config.services.asusd.enable
"special:rog, decorate:false")
(mkIf config.services.asusd.enable "special:rog, decorate:false")
"special:keepassxc, decorate:false"
];
@ -283,19 +318,17 @@ in {
"size 70% 70%, class:^(code), title: ^(Open*)"
"center, class: ^(code), title: ^(Open*)"
"float, class:^(org.keepassxc.KeePassXC)$"
(mkIf config.services.asusd.enable
"size 960 670, title:^(ROG Control Center)$")
(mkIf config.services.asusd.enable "size 960 670, title:^(ROG Control Center)$")
(mkIf cfg.tearing
"immediate, class:^(osu!)$")
(mkIf cfg.tearing "immediate, class:^(osu!)$")
];
bind = [
"$mainMod, RETURN, exec, ${foot}/bin/${if config.myOptions.programs.foot.server then "footclient" else "foot"}"
"$mainMod, RETURN, exec, ${if config.myOptions.programs.foot.server then footclient else foot}"
"$mainMod, Q, killactive"
"$mainMod, F, fullscreen, 0"
"$mainMod, M, fullscreen, 1"
"$mainMod, D, exec, ${pkgs.procps}/bin/pkill anyrun || ${anyrun}/bin/anyrun"
"$mainMod, D, exec, ${pkill} anyrun || ${anyrun}"
"$mainMod, SPACE, togglefloating, active"
"$mainMod SHIFT, C, centerwindow"
"$mainMod CONTROL, R, bringactivetotop"
@ -322,46 +355,41 @@ in {
"$mainMod SHIFT, 9, ${if smwPresent then "split-" else ""}movetoworkspacesilent, 9"
"$mainMod SHIFT, 0, ${if smwPresent then "split-" else ""}movetoworkspacesilent, 10"
# screenshots
"$mainMod, S, exec, ${hyprcontrib.grimblast}/bin/grimblast save area - | ${pkgs.coreutils-full}/bin/tee \"$(${pkgs.xdg-user-dirs}/bin/xdg-user-dir PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-clipboard}/bin/wl-copy && ${pkgs.libnotify}/bin/notify-send \"Screenshot taken\""
"$mainMod SHIFT, S, exec, ${hyprcontrib.grimblast}/bin/grimblast save area - | ${shadower}/bin/shadower | ${pkgs.coreutils-full}/bin/tee \"$(${pkgs.xdg-user-dirs}/bin/xdg-user-dir PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-clipboard}/bin/wl-copy && ${pkgs.libnotify}/bin/notify-send \"Screenshot taken (shadower)\""
"$mainMod CONTROL, S, exec, ${hyprcontrib.grimblast}/bin/grimblast save area - | ${pkgs.swappy}/bin/swappy -f - -o - | ${pkgs.coreutils-full}/bin/tee \"$(${pkgs.xdg-user-dirs}/bin/xdg-user-dir PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-clipboard}/bin/wl-copy && ${pkgs.libnotify}/bin/notify-send \"Screenshot taken\""
"$mainMod SHIFT CONTROL, S, exec, ${hyprcontrib.grimblast}/bin/grimblast save area - | ${pkgs.swappy}/bin/swappy -f - -o - | ${shadower}/bin/shadower | ${pkgs.coreutils-full}/bin/tee \"$(${pkgs.xdg-user-dirs}/bin/xdg-user-dir PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-clipboard}/bin/wl-copy && ${pkgs.libnotify}/bin/notify-send \"Screenshot taken (shadower)\""
"$mainMod SHIFT, R, exec, ${hyprland}/bin/hyprctl reload"
"$mainMod, S, exec, ${grimblast} save area - | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken\""
"$mainMod SHIFT, S, exec, ${grimblast} save area - | ${shadower} | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken (shadower)\""
"$mainMod CONTROL, S, exec, ${grimblast} save area - | ${swappy} -f - -o - | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken\""
"$mainMod SHIFT CONTROL, S, exec, ${grimblast} save area - | ${swappy} -f - -o - | ${shadower} | ${tee} \"$(${xdg-user-dir} PICTURES)/Screenshots/$(date +'screenshot-%Y%m%d%H%M%S.png')\" | ${wl-copy} && ${notify-send} \"Screenshot taken (shadower)\""
"$mainMod SHIFT, R, exec, ${hyprctl} reload"
(mkIf config.services.asusd.enable
", XF86Launch3, exec, ${config.services.asusd.package}/bin/asusctl led-mode -n")
(mkIf config.services.asusd.enable
", XF86Launch4, exec, ${config.services.asusd.package}/bin/asusctl profile -n")
(mkIf config.services.asusd.enable ", XF86Launch3, exec, ${asusctl} led-mode -n")
(mkIf config.services.asusd.enable ", XF86Launch4, exec, ${asusctl} profile -n")
# TODO what the fuck is this
", XF86TouchpadToggle, exec, "
# TODO fix this maybe
"$mainMod, T, exec, grim -g \"$(slurp)\" -t ppm - | tesseract -l pol - - | wl-copy && ${pkgs.libnotify}/bin/notify-send \"Copied text: \" \"\\\"$(wl-paste)\\\"\""
"$mainMod, T, exec, grim -g \"$(slurp)\" -t ppm - | tesseract -l pol - - | wl-copy && ${notify-send} \"Copied text: \" \"\\\"$(wl-paste)\\\"\""
# TODO fix this
"$mainMod, SEMICOLON, exec, ~/.config/rofi/powermenu/type-2/powermenu.sh"
"$mainMod, G, togglegroup"
# this sometimes fixes the portal
"$mainMod CONTROL, K, exec, ${pkgs.systemd}/bin/systemctl --user restart xdg-desktop-portal-hyprland"
"$mainMod SHIFT, K, exec, ${hyprland}/bin/hyprctl kill"
"$mainMod CONTROL, K, exec, ${systemctl} --user restart xdg-desktop-portal-hyprland"
"$mainMod SHIFT, K, exec, ${hyprctl} kill"
# scratchpad binds
"$mainMod, B, togglespecialworkspace, btop"
(mkIf isAmdGpuPresent
"$mainMod, A, togglespecialworkspace, amdgpu_top")
"$mainMod, V, togglespecialworkspace, pipewire"
"$mainMod, N, togglespecialworkspace, nixos"
"$mainMod, B, togglespecialworkspace, btop"
(mkIf isAmdGpuPresent "$mainMod, A, togglespecialworkspace, amdgpu_top")
"$mainMod, V, togglespecialworkspace, pipewire"
"$mainMod, N, togglespecialworkspace, nixos"
# rog button on laptop keyboard
(mkIf config.services.asusd.enable
", XF86Launch1, togglespecialworkspace, rog")
(mkIf config.services.asusd.enable
"$mainMod, R, togglespecialworkspace, rog")
"$mainMod, X, togglespecialworkspace, keepassxc"
"$mainMod, C, exec, ${pkgs.systemd}/bin/loginctl lock-session"
(mkIf config.services.asusd.enable ", XF86Launch1, togglespecialworkspace, rog")
(mkIf config.services.asusd.enable "$mainMod, R, togglespecialworkspace, rog")
"$mainMod, X, togglespecialworkspace, keepassxc"
"$mainMod, C, exec, ${loginctl} lock-session"
# toggle waybar
"$mainMod CONTROL, B, exec, ${pkgs.procps}/bin/pkill waybar || ${waybar}/bin/waybar"
"$mainMod CONTROL, minus, exec, ${hyprland}/bin/hyprctl keyword misc:cursor_zoom_factor 2"
"$mainMod CONTROL, apostrophe, exec, ${hyprland}/bin/hyprctl keyword misc:cursor_zoom_factor 1"
"$mainMod, Z, exec, ${woomer}/bin/woomer"
"$mainMod CONTROL, B, exec, ${pkill} waybar || ${waybar}"
"$mainMod CONTROL, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor 2"
"$mainMod CONTROL, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor 1"
"$mainMod, Z, exec, ${woomer}"
# I love Microsoft !!!!!!
"$mainMod ALT CONTROL SHIFT, L, exec, ${pkgs.xdg-utils}/bin/xdg-open https://www.linkedin.com/"
"$mainMod ALT CONTROL SHIFT, L, exec, ${xdg-open} https://www.linkedin.com/"
];
# repeat
@ -374,25 +402,23 @@ in {
"$mainMod, L, focusmonitor, r"
# keyboard brightness
(mkIf config.services.asusd.enable
", XF86KbdBrightnessUp, exec, ${config.services.asusd.package}/bin/asusctl -n")
(mkIf config.services.asusd.enable
", XF86KbdBrightnessDown, exec, ${config.services.asusd.package}/bin/asusctl -p")
(mkIf config.services.asusd.enable ", XF86KbdBrightnessUp, exec, ${asusctl} -n")
(mkIf config.services.asusd.enable ", XF86KbdBrightnessDown, exec, ${asusctl} -p")
"$mainMod SHIFT, G, changegroupactive, f"
"$mainMod CONTROL, G, changegroupactive, b"
"$mainMod, minus, exec, ${hyprland}/bin/hyprctl keyword misc:cursor_zoom_factor \"$(${hyprland}/bin/hyprctl getoption misc:cursor_zoom_factor | rg float | awk '{print $2 + 0.05}')\""
"$mainMod, apostrophe, exec, ${hyprland}/bin/hyprctl keyword misc:cursor_zoom_factor \"$(${hyprland}/bin/hyprctl getoption misc:cursor_zoom_factor | rg float | awk '{if($2 != 1) {print $2 - 0.05}}')\""
"$mainMod, minus, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${gawk} '{print $2 + 0.05}')\""
"$mainMod, apostrophe, exec, ${hyprctl} keyword misc:cursor_zoom_factor \"$(${hyprctl} getoption misc:cursor_zoom_factor | ${rg} float | ${gawk} '{if($2 != 1) {print $2 - 0.05}}')\""
];
# locked
bindl = let
play-pause = "${pkgs.playerctl}/bin/playerctl play-pause";
stop = "${pkgs.playerctl}/bin/playerctl stop";
prev = "${pkgs.playerctl}/bin/playerctl previous";
next = "${pkgs.playerctl}/bin/playerctl next";
toggle-mute = "${pkgs.pamixer}/bin/pamixer --toggle-mute";
play-pause = "${playerctl} play-pause";
stop = "${playerctl} stop";
prev = "${playerctl} previous";
next = "${playerctl} next";
toggle-mute = "${pamixer} --toggle-mute";
in [
", XF86AudioMedia, exec, ${play-pause}"
", XF86AudioPlay, exec, ${play-pause}"
@ -409,10 +435,10 @@ in {
# locked + repeat
bindle = let
brightness_up = "${pkgs.brightnessctl}/bin/brightnessctl set +5%";
brightness_down = "${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
volume_up = "${pkgs.pamixer}/bin/pamixer -ui 5";
volume_down = "${pkgs.pamixer}/bin/pamixer -ud 5";
brightness_up = "${brightnessctl} set +5%";
brightness_down = "${brightnessctl} set 5%-";
volume_up = "${pamixer} -ui 5";
volume_down = "${pamixer} -ud 5";
in [
# TODO integrate the scripts from https://codeberg.org/jacekpoz/dotconfig/src/branch/master/Scripts
", XF86MonBrightnessUp, exec, ${brightness_up}"
@ -438,13 +464,13 @@ in {
exec-once = let
# https://wiki.hyprland.org/IPC/#how-to-use-socket2-with-bash
handle_hyprland_events = pkgs.writeShellScriptBin "handle_hyprland_events" ''
handle_hyprland_events = pkgs.writeShellScript "handle_hyprland_events" ''
#!/bin/sh
handle() {
case $1 in
configreloaded*)
${hyprland}/bin/hyprctl notify 1 2500 "" " Reloading Hyprland..."
${hyprctl} notify 1 2500 "" " Reloading Hyprland..."
;;
esac
}
@ -455,49 +481,47 @@ in {
done
'';
in [
"${waybar}/bin/waybar"
"${waybar}"
# run persistent special workspace windows
"[workspace special:nixos silent;tile] cd ~/niksos; ${foot}/bin/foot"
(mkIf config.services.asusd.enable
"[workspace special:rog silent;tile] ${config.services.asusd.package}/bin/rog-control-center")
"[workspace special:keepassxc silent;tile] ${pkgs.keepassxc}/bin/keepassxc"
"[workspace special:nixos silent;tile] cd ~/niksos; ${foot}"
(mkIf config.services.asusd.enable "[workspace special:rog silent;tile] ${rog-control-center}")
"[workspace special:keepassxc silent;tile] ${keepassxc}"
(if config.myOptions.programs.foot.server then "sleep 0.5 && ${pkgs.systemd}/bin/systemctl --user restart foot.service" else ";")
(mkIf config.myOptions.programs.foot.server "sleep 0.5 && ${systemctl} --user restart foot.service")
"${hyprland}/bin/hyprctl setcursor Bibata-Modern-Classic 24"
"${hyprctl} setcursor Bibata-Modern-Classic 24"
# TODO do something with this
#"${wl-clipboard}/bin/wl-paste --watch cliphist store"
#"${wl-paste} --watch cliphist store"
"${swww}/bin/swww init"
"${wlsunset}/bin/wlsunset -S 06:00 -s 20:00"
"${swww} init"
"${wlsunset} -S 06:00 -s 20:00"
# TODO fix fcitx5
#"fcitx5"
# TODO do these do anything anymore
"${pkgs.systemd}/bin/systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
"${pkgs.dbus}/bin/dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP"
"${handle_hyprland_events}/bin/handle_hyprland_events"
"${systemctl} --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
"${dbus-update-activation-environment} --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP"
"${handle_hyprland_events}"
] ++ cfg.extraSettings.exec-once;
exec = [
# kill (almost) everything on special workspaces
"${pkgs.procps}/bin/pkill btop"
(mkIf isAmdGpuPresent
"${pkgs.procps}/bin/pkill amdgpu_top")
"${pkgs.procps}/bin/pkill helvum"
"${pkgs.procps}/bin/pkill pwvucontrol"
"${pkill} btop"
(mkIf isAmdGpuPresent "${pkill} amdgpu_top")
"${pkill} helvum"
"${pkill} pwvucontrol"
# and run it all again
"[workspace special:btop silent;tile] ${foot}/bin/foot -e ${pkgs.btop}/bin/btop"
"[workspace special:btop silent;tile] ${foot} -e ${btop}"
(mkIf isAmdGpuPresent
"[workspace special:amdgpu_top silent;tile] ${foot}/bin/foot -e ${pkgs.amdgpu_top}/bin/amdgpu_top -i 0")
"[workspace special:amdgpu_top silent;tile] ${foot} -e ${amdgpu_top} -i 0")
(mkIf isAmdGpuPresent
"[workspace special:amdgpu_top silent;tile] ${foot}/bin/foot -e ${pkgs.amdgpu_top}/bin/amdgpu_top -i 1")
"[workspace special:pipewire silent;tile] ${pkgs.helvum}/bin/helvum"
"[workspace special:pipewire silent;tile] ${pkgs.pwvucontrol}/bin/pwvucontrol"
"[workspace special:amdgpu_top silent;tile] ${foot} -e ${amdgpu_top} -i 1")
"[workspace special:pipewire silent;tile] ${helvum}"
"[workspace special:pipewire silent;tile] ${pwvucontrol}"
"${pkgs.networkmanagerapplet}/bin/nm-applet --indicator"
"${pkgs.blueman}/bin/blueman-applet"
"${nm-applet} --indicator"
"${blueman-applet}"
] ++ cfg.extraSettings.exec;
layerrule = [