dotfiles

My PC Dotfiles & Website

modules/desktop/hyprland/_settings/apps.nix (6140B)


  1_: {
  2  config,
  3  lib,
  4  pkgs,
  5  osConfig ? null,
  6  ...
  7}:
  8lib.mkIf (osConfig != null) (
  9  let
 10    lua = import ./_lib.nix lib;
 11    inherit (lua) combo bind exec env on permission;
 12
 13    inherit (osConfig.gui) display;
 14    inherit (config.stylix) cursor;
 15    hyprcursor = "${cursor.name}-Hyprcursor";
 16
 17    mod = "SUPER";
 18
 19    unit = command: lib.head (lib.splitString " " command);
 20    runOnce = app: "pgrep ${app} || uwsm app -u ${app}.scope -- ${app}";
 21  in {
 22    ## App Environment
 23    # Cursor
 24    xdg.dataFile."icons/${hyprcursor}".source = "${cursor.package}/share/icons/${hyprcursor}";
 25    wayland.windowManager.hyprland.settings = {
 26      env = [
 27        (env "HYPRCURSOR_THEME" hyprcursor)
 28        (env "HYPRCURSOR_SIZE" (toString cursor.size))
 29
 30        # QT Apps
 31        (env "QT_WAYLAND_DISABLE_WINDOWDECORATION" "1")
 32      ];
 33
 34      ## Autostart
 35      on = [
 36        (on "hyprland.start" ("function() "
 37          + lib.concatStringsSep " " (map (c: ''hl.exec_cmd("${c}");'') (
 38            [
 39              "uwsm finalize"
 40              "hyprctl setcursor ${hyprcursor} ${toString cursor.size}"
 41            ]
 42            ++ (map (app: "uwsm app -t service -u ${unit app}.service -- ${app}") [
 43              # Pyprland
 44              "pypr"
 45
 46              # Desktop Icons
 47              "pcmanfm-qt --desktop"
 48            ])
 49          ))
 50          + " end"))
 51      ];
 52
 53      ## Shortcuts
 54      bind = [
 55        # Applications
 56        (bind (combo [mod] "F") (exec "nemo"))
 57        (bind (combo [mod] "T") (exec "kitty"))
 58        (bind (combo [mod] "W") (exec "firefox"))
 59        (bind (combo [mod] "Return") (exec (runOnce "resources")))
 60        (bind (combo [mod "SHIFT"] "equal") (exec "pypr toggle calc"))
 61        (bind (combo [] "XF86Calculator") (exec "qalculate-gtk"))
 62
 63        # Utilities
 64        (bind (combo [mod] "A") (exec "noctalia msg panel-toggle launcher"))
 65        (bind (combo [mod] "slash") (exec "noctalia msg plugin maydayv7/keyhelp:controller all toggle hyprland"))
 66        (bind (combo [mod "SHIFT"] "C") (exec "${runOnce "hyprpicker"} -arf hex"))
 67        (bind (combo [mod "SHIFT"] "B") (exec (runOnce "overskride")))
 68        (bind (combo [mod] "D") (exec (runOnce "nwg-displays")))
 69        (bind (combo [mod "SHIFT"] "P") (exec "pwvucontrol"))
 70        (bind (combo [mod "SHIFT"] "N") (exec "sh -c 'env XDG_CURRENT_DESKTOP=GNOME gnome-control-center wifi'"))
 71        (bind (combo [mod] "Escape") (exec "noctalia msg panel-toggle session"))
 72
 73        # Shell
 74        (bind (combo [mod "SHIFT"] "A") (exec "noctalia msg settings-toggle"))
 75        (bind (combo [mod] "Tab") (exec "noctalia msg window-switcher"))
 76        (bind (combo [mod] "N") (exec "noctalia msg panel-toggle notifications"))
 77        (bind (combo [mod] "V") (exec "noctalia msg panel-toggle clipboard"))
 78
 79        # Tools
 80        (bind (combo [mod] "G") (exec "hyprutils gamemode"))
 81        (bind (combo [mod "SHIFT"] "D") (exec "hyprutils toggle monitor ${display}"))
 82        (bind (combo [mod] "S") (exec "hyprutils toggle shader"))
 83        (bind (combo [mod "SHIFT"] "T") (exec "pypr toggle term"))
 84      ];
 85
 86      ## Permissions
 87      permission = [
 88        (permission "${osConfig.programs.hyprland.portalPackage}/libexec/.xdg-desktop-portal-hyprland-wrapped" "screencopy" "allow")
 89        (permission (lib.getExe pkgs.gpu-screen-recorder) "screencopy" "allow")
 90      ];
 91
 92      ## Layer Rules
 93      layer_rule = [
 94        {
 95          match.namespace = "^(hyprpicker)$";
 96          no_anim = true;
 97        }
 98        {
 99          match.namespace = "^(noctalia-.*)$";
100          blur = true;
101          ignore_alpha = 0.6;
102        }
103        {
104          match.namespace = "^(noctalia-wallpaper)$";
105          order = 1;
106        }
107        {
108          match.namespace = "^(desktop)$";
109          order = 0;
110        }
111      ];
112
113      ## Window Rules
114      window_rule =
115        [
116          # Settings
117          {
118            match.class = "^(gnome-control-center)$";
119            stay_focused = true;
120          }
121
122          # Browser Windows
123          {
124            match.title = "^(Picture-in-[P|p]icture)$";
125            float = true;
126          }
127          {
128            match.title = "^(Sharing Indicator)$";
129            workspace = "special silent";
130          }
131          {
132            match.title = "^(.*is sharing (your screen|a window).)$";
133            workspace = "special silent";
134          }
135
136          # Media Consumption
137          {
138            match.class = "^(mpv|.*celluloid.*|.+exe)$";
139            idle_inhibit = "focus";
140          }
141          {
142            match = {
143              class = "^(firefox|brave-browser)$";
144              title = "^(.*YouTube.*)$";
145            };
146            idle_inhibit = "focus";
147          }
148          {
149            match.class = "^(firefox|brave-browser)$";
150            idle_inhibit = "fullscreen";
151          }
152
153          # Screen Tearing
154          {
155            match.class = "^(.+exe)$";
156            immediate = true;
157          }
158
159          # Prompt Windows
160          {
161            match.class = "^(xdg-desktop-portal-gtk)$";
162            float = true;
163            dim_around = true;
164          }
165        ]
166        ++ (map (class: {
167            # Authentication
168            match.class = "^(${class})$";
169            pin = true;
170            dim_around = true;
171            stay_focused = true;
172          }) [
173            "pinentry-"
174            "gcr-prompter"
175          ])
176        ++ (map (class: {
177            # Utilities
178            match.class = "^(${class})$";
179            float = true;
180            pin = true;
181            persistent_size = true;
182          }) [
183            "com.saivert.pwvucontrol"
184            "io.github.kaii_lb.Overskride"
185            "nwg-displays"
186            "gnome-control-center"
187            "org.gnome.Settings"
188          ])
189        ++ (map (title: {
190            # Dialogs
191            match.title = "^(${title})(.*)$";
192            float = true;
193          }) [
194            "Library"
195            "Open File"
196            "Open Folder"
197            "Save As"
198            "Save File"
199            "Select a File"
200            "Extract"
201            ".*Properties"
202          ]);
203    };
204  }
205)