2024-09-09 00:22:14 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-09-11 23:16:44 +00:00
|
|
|
with lib; let
|
2024-09-25 20:05:04 +00:00
|
|
|
_1password = "${config.programs._1password-gui.package}/bin/1password";
|
2024-09-09 00:22:14 +00:00
|
|
|
gamescope = "${config.programs.gamescope.package}/bin/gamescope";
|
2024-09-25 20:02:50 +00:00
|
|
|
hyprctl = "${config.programs.hyprland.package}/bin/hyprctl";
|
2024-09-11 23:16:44 +00:00
|
|
|
kitty = "${config.home-manager.users.${config.custom.username}.programs.kitty.package}/bin/kitty";
|
2024-09-27 20:12:15 +00:00
|
|
|
launch = config.home-manager.users.${config.custom.username}.home.file.".local/bin/launch".source;
|
2024-11-25 18:00:06 +00:00
|
|
|
libreoffice = "${config.custom.programs.libreoffice.package}/bin/libreoffice";
|
2024-09-09 00:22:14 +00:00
|
|
|
loupe = "${pkgs.loupe}/bin/loupe";
|
2024-11-12 20:27:22 +00:00
|
|
|
onlyoffice-desktopeditors = "${pkgs.onlyoffice-bin}/bin/onlyoffice-desktopeditors --system-title-bar --xdg-desktop-portal";
|
2024-09-11 23:16:44 +00:00
|
|
|
pgrep = "${pkgs.procps}/bin/pgrep";
|
2024-09-09 00:22:14 +00:00
|
|
|
steam = "${config.programs.steam.package}/bin/steam";
|
|
|
|
virt-manager = "${pkgs.virt-manager}/bin/virt-manager";
|
|
|
|
waydroid = "${pkgs.waydroid}/bin/waydroid";
|
|
|
|
youtube-music = "${pkgs.youtube-music}/bin/youtube-music";
|
|
|
|
|
|
|
|
cfg = config.custom.desktops.hyprland.rules;
|
2024-09-11 23:16:44 +00:00
|
|
|
in {
|
|
|
|
options.custom.desktops.hyprland.rules.enable = mkOption {default = false;};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
|
|
|
|
wayland.windowManager.hyprland.settings = {
|
2024-09-27 01:54:38 +00:00
|
|
|
# BUG: on-created-empty race condition with delayed windows
|
|
|
|
# https://github.com/hyprwm/Hyprland/issues/5663
|
2024-09-09 00:22:14 +00:00
|
|
|
# https://wiki.hyprland.org/Configuring/Workspace-Rules
|
|
|
|
#?? workspace = WORKSPACE, RULES
|
|
|
|
workspace = [
|
2024-11-12 20:27:57 +00:00
|
|
|
"special:android, on-created-empty:${launch} --workspace special:android --empty ${waydroid} app launch com.YoStarEN.Arknights"
|
2024-11-08 20:34:18 +00:00
|
|
|
"special:gamescope, on-created-empty:MANGOHUD=0 ${gamescope} --fullscreen --steam ${steam}"
|
2024-09-09 00:22:14 +00:00
|
|
|
"special:music, on-created-empty:${youtube-music}"
|
2024-11-25 18:00:06 +00:00
|
|
|
"special:office, on-created-empty:${launch} --workspace special:office --empty --tile -- ${libreoffice}"
|
2024-11-12 20:27:57 +00:00
|
|
|
"special:password, on-created-empty:${launch} --workspace special:password --empty ${_1password}"
|
2024-09-09 00:22:14 +00:00
|
|
|
"special:steam, on-created-empty:${steam}"
|
|
|
|
"special:terminal, on-created-empty:${kitty}"
|
2024-11-12 20:27:57 +00:00
|
|
|
"special:vm, on-created-empty:${launch} --workspace special:vm --empty ${virt-manager}"
|
2024-11-08 21:58:57 +00:00
|
|
|
"special:wallpaper, on-created-empty:${loupe} /tmp/wallpaper.png"
|
2024-09-09 00:22:14 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# https://wiki.hyprland.org/Configuring/Window-Rules
|
|
|
|
#?? windowrulev2 = RULE, WINDOW
|
2024-09-11 23:16:44 +00:00
|
|
|
windowrulev2 = with config.custom; let
|
2024-09-15 00:58:03 +00:00
|
|
|
# HACK: Attempts to account for hypr-specific scale, gaps, borders, and bar padding
|
|
|
|
### Static geometry rules
|
|
|
|
tr = num: toString (builtins.floor num); # Convert truncated float to string
|
2024-09-11 23:16:44 +00:00
|
|
|
|
2024-10-29 22:02:07 +00:00
|
|
|
# Bottom center
|
|
|
|
android = rec {
|
|
|
|
x = tr (width / scale / 2 - (toInt w) / 2);
|
|
|
|
y = tr (height
|
|
|
|
/ scale
|
|
|
|
- (toInt h)
|
|
|
|
- gap
|
|
|
|
- padding
|
|
|
|
+ (
|
|
|
|
if ultrawide
|
|
|
|
then - border # Cause unknown
|
|
|
|
else 0
|
|
|
|
));
|
|
|
|
w = tr (
|
|
|
|
width
|
|
|
|
/ scale
|
|
|
|
* (
|
|
|
|
if ultrawide
|
|
|
|
then 0.5 # 50%
|
|
|
|
else 1
|
|
|
|
)
|
|
|
|
+ (
|
|
|
|
if ultrawide
|
|
|
|
then - gap / 2 * 2 # Center layout padding between windows
|
|
|
|
else - gap * 2
|
|
|
|
)
|
|
|
|
- border * 2
|
|
|
|
);
|
|
|
|
h = tr (height / scale * 0.5); # 50%
|
|
|
|
};
|
|
|
|
|
2024-09-11 23:16:44 +00:00
|
|
|
# Bottom center
|
|
|
|
clipboard = rec {
|
|
|
|
x = tr (width / scale / 2 - (toInt w) / 2);
|
2024-09-15 00:58:03 +00:00
|
|
|
y = tr (height
|
|
|
|
/ scale
|
|
|
|
- (toInt h)
|
|
|
|
- gap
|
|
|
|
- padding
|
|
|
|
+ (
|
|
|
|
if ultrawide
|
|
|
|
then - border # Cause unknown
|
|
|
|
else 0
|
|
|
|
));
|
2024-09-11 23:16:44 +00:00
|
|
|
w = "600";
|
2024-09-15 00:58:03 +00:00
|
|
|
h = tr (height / scale * 0.75); # 75%
|
2024-09-11 23:16:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Bottom center
|
|
|
|
dropdown = rec {
|
|
|
|
x = tr (width / scale / 2 - (toInt w) / 2);
|
2024-09-15 00:58:03 +00:00
|
|
|
y = tr (height
|
|
|
|
/ scale
|
|
|
|
- (toInt h)
|
|
|
|
- gap
|
|
|
|
- padding
|
|
|
|
+ (
|
|
|
|
if ultrawide
|
|
|
|
then - border # Cause unknown
|
|
|
|
else 0
|
|
|
|
));
|
|
|
|
w = tr (
|
|
|
|
width
|
2024-09-11 23:16:44 +00:00
|
|
|
/ scale
|
|
|
|
* (
|
|
|
|
if ultrawide
|
2024-09-15 00:58:03 +00:00
|
|
|
then 0.5 # 50%
|
2024-09-11 23:16:44 +00:00
|
|
|
else 1
|
|
|
|
)
|
2024-09-15 00:58:03 +00:00
|
|
|
+ (
|
|
|
|
if ultrawide
|
|
|
|
then - gap / 2 * 2 # Center layout padding between windows
|
2024-09-15 01:17:54 +00:00
|
|
|
else - gap * 2
|
2024-09-15 00:58:03 +00:00
|
|
|
)
|
|
|
|
- border * 2
|
|
|
|
);
|
|
|
|
h = tr (height
|
|
|
|
/ scale
|
|
|
|
* (
|
|
|
|
if ultrawide
|
|
|
|
then 0.2 # 20%
|
|
|
|
else 0.3 # 30%
|
|
|
|
));
|
2024-09-11 23:16:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Top right
|
|
|
|
pip = rec {
|
|
|
|
x = tr (width / scale - (toInt w) - gap - border);
|
|
|
|
y = tr (gap + border);
|
2024-09-15 00:58:03 +00:00
|
|
|
w = tr (width / scale * 0.25 - gap - gap / 2 - border * 2); # 25%
|
2024-10-15 23:05:59 +00:00
|
|
|
h = tr ((toInt w) * 9 / 16 + 1); # 16:9 aspect ratio
|
2024-09-11 23:16:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
### Rules
|
|
|
|
# Return hypr-formatted string, converting booleans into 0/1
|
|
|
|
format = field: expr: "${field}:${
|
|
|
|
toString (
|
|
|
|
if expr == true
|
|
|
|
then 1
|
|
|
|
else if expr == false
|
|
|
|
then 0
|
|
|
|
else expr
|
|
|
|
)
|
|
|
|
}";
|
|
|
|
|
|
|
|
# Generate hypr-formatted window rules
|
|
|
|
#?? merge <FIELD|{FIELDS}> <EXPRESSION> <RULES>
|
|
|
|
merge = field: expr: rules:
|
|
|
|
map (
|
|
|
|
rule:
|
|
|
|
if builtins.isAttrs field
|
|
|
|
then "${rule}, ${lib.concatStringsSep ", " (lib.mapAttrsToList (f: e: format f e) field)}"
|
|
|
|
else "${rule}, ${format field expr}"
|
|
|
|
)
|
|
|
|
rules;
|
|
|
|
|
|
|
|
class = expr: rules: merge "class" "^${expr}$" rules;
|
|
|
|
floating = expr: rules: merge "floating" expr rules;
|
|
|
|
fullscreen = expr: rules: merge "fullscreen" expr rules;
|
|
|
|
pinned = expr: rules: merge "pinned" expr rules;
|
|
|
|
title = expr: rules: merge "title" "^${expr}$" rules;
|
|
|
|
|
|
|
|
fields = fields: rules: merge fields null rules;
|
|
|
|
|
|
|
|
### Pseudo-tags
|
|
|
|
# Wrap generated rules in Nix categories
|
|
|
|
tag = {
|
|
|
|
android = rules: [
|
2024-10-28 01:44:12 +00:00
|
|
|
(class "[Ww]aydroid.*" rules)
|
2024-09-11 23:16:44 +00:00
|
|
|
];
|
2024-11-08 20:34:18 +00:00
|
|
|
browser = rules: [
|
|
|
|
(fields {
|
|
|
|
class = "^chromium-browser$";
|
|
|
|
title = "^(?!Picture.in.[Pp]icture).*$";
|
|
|
|
}
|
|
|
|
rules)
|
|
|
|
(fields {
|
2024-11-27 23:03:53 +00:00
|
|
|
class = "^firefox.*$";
|
2024-11-08 20:34:18 +00:00
|
|
|
title = "^(?!Picture.in.[Pp]icture).*$";
|
|
|
|
}
|
|
|
|
rules)
|
|
|
|
];
|
2024-09-11 23:16:44 +00:00
|
|
|
clipboard = rules: [
|
|
|
|
(class "clipboard" rules)
|
|
|
|
];
|
|
|
|
dropdown = rules: [
|
|
|
|
(class "dropdown" rules)
|
|
|
|
];
|
|
|
|
editor = rules: [
|
2024-11-27 22:23:55 +00:00
|
|
|
(class "codium" rules) # VSCode
|
2024-10-26 18:16:03 +00:00
|
|
|
(class "obsidian" (rules ++ ["group barred"]))
|
2024-09-11 23:16:44 +00:00
|
|
|
];
|
|
|
|
files = rules: [
|
|
|
|
(class "org\\.gnome\\.Nautilus" rules)
|
|
|
|
];
|
|
|
|
game = rules: [
|
2024-12-12 03:23:29 +00:00
|
|
|
(class ".*\\.(exe|x86_64)" rules) # Wine
|
2024-11-30 22:02:08 +00:00
|
|
|
(class "moe\\.launcher\\..+" (rules ++ ["size 1280 730"])) # An Anime Game Launcher
|
2024-09-21 19:23:57 +00:00
|
|
|
(class "net.retrodeck.retrodeck" rules) # Emulators
|
2024-09-11 23:16:44 +00:00
|
|
|
(class "steam_app_.+" rules) # Proton
|
|
|
|
];
|
2024-09-26 21:18:56 +00:00
|
|
|
media = rules: [
|
|
|
|
(class "org\\.gnome\\.Loupe" rules)
|
|
|
|
(class "totem" rules)
|
|
|
|
];
|
2024-09-11 23:16:44 +00:00
|
|
|
music = rules: [
|
|
|
|
(class "Spotify" rules)
|
|
|
|
(class "YouTube Music" rules)
|
|
|
|
(title "Spotify Premium" rules)
|
|
|
|
];
|
|
|
|
office = rules: [
|
2024-11-24 19:12:48 +00:00
|
|
|
(class "draw\\.io" rules)
|
2024-09-11 23:16:44 +00:00
|
|
|
(class "libreoffice.+" rules)
|
2024-09-14 21:03:48 +00:00
|
|
|
(class "ONLYOFFICE Desktop Editors" rules)
|
2024-09-11 23:16:44 +00:00
|
|
|
];
|
2024-09-25 20:05:04 +00:00
|
|
|
password = rules: [
|
2024-11-12 20:27:57 +00:00
|
|
|
(class "1Password" rules)
|
2024-09-25 20:05:04 +00:00
|
|
|
(class "Bitwarden" rules)
|
|
|
|
];
|
2024-09-11 23:16:44 +00:00
|
|
|
pip = rules: [
|
|
|
|
(title "Picture.in.[Pp]icture" rules)
|
|
|
|
];
|
|
|
|
social = rules: [
|
|
|
|
(class "cinny" rules)
|
|
|
|
(class "discord" rules)
|
|
|
|
(class "Element" rules)
|
|
|
|
(class "org\\.telegram\\.desktop" rules)
|
|
|
|
];
|
|
|
|
steam = rules: [
|
|
|
|
(class "SDL Application" rules) # Steam
|
|
|
|
(class "steam" rules)
|
|
|
|
];
|
|
|
|
terminal = rules: [
|
|
|
|
(class "foot" rules)
|
|
|
|
(class "kitty" rules)
|
|
|
|
(class "org\\.wezfurlong\\.wezterm" rules)
|
|
|
|
];
|
|
|
|
vm = rules: [
|
|
|
|
(class "(sdl-|wl|x)freerdp" (rules ++ ["nomaxsize" "tile"]))
|
2024-12-07 01:47:20 +00:00
|
|
|
(class "looking-glass-client" rules)
|
2024-11-17 20:14:23 +00:00
|
|
|
(class "org\\.remmina\\.Remmina" (rules ++ ["tile"]))
|
2024-09-11 23:16:44 +00:00
|
|
|
(class "virt-manager" rules)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
2024-09-09 00:22:14 +00:00
|
|
|
flatten [
|
|
|
|
### Defaults
|
2024-10-26 17:15:29 +00:00
|
|
|
(class ".*" ["float" "group barred" "suppressevent maximize"])
|
2024-09-12 17:59:37 +00:00
|
|
|
(floating false ["noshadow"])
|
2024-10-13 22:15:40 +00:00
|
|
|
(floating true ["noborder"])
|
2024-09-11 23:16:44 +00:00
|
|
|
(fullscreen true ["idleinhibit focus"])
|
|
|
|
(pinned true ["bordercolor rgb(073642) rgb(073642)"])
|
|
|
|
|
2024-11-12 20:27:57 +00:00
|
|
|
(tag.android ["idleinhibit always" "move ${android.x} ${android.y}" "size ${android.w} ${android.h}" "workspace special:android"])
|
2024-11-08 20:34:18 +00:00
|
|
|
(tag.browser ["group override set" "tile" "workspace 1"])
|
2024-09-11 23:16:44 +00:00
|
|
|
(tag.clipboard ["move ${clipboard.x} ${clipboard.y}" "pin" "size ${clipboard.w} ${clipboard.h}" "stayfocused"])
|
|
|
|
(tag.dropdown ["move ${dropdown.x} ${dropdown.y}" "pin" "size ${dropdown.w} ${dropdown.h}"])
|
2024-10-26 18:16:03 +00:00
|
|
|
(tag.editor ["group override set" "tile"])
|
2024-11-24 19:12:48 +00:00
|
|
|
(tag.files ["center"])
|
2024-11-17 00:39:58 +00:00
|
|
|
(tag.game ["idleinhibit always" "noborder" "noshadow" "renderunfocused" "workspace name:game"])
|
2024-11-08 20:34:18 +00:00
|
|
|
(tag.media ["center" "keepaspectratio" "size <90% <90%"])
|
2024-09-11 23:16:44 +00:00
|
|
|
(tag.music ["tile" "workspace special:music"])
|
2024-11-24 19:12:48 +00:00
|
|
|
(tag.office ["group override set" "tile" "workspace special:office"])
|
2024-11-08 20:34:18 +00:00
|
|
|
(tag.password ["center" "tile" "workspace special:password"])
|
2024-10-26 17:15:29 +00:00
|
|
|
(tag.pip ["keepaspectratio" "move ${pip.x} ${pip.y}" "noinitialfocus" "pin" "size ${pip.w} ${pip.h}"])
|
2024-10-26 18:16:03 +00:00
|
|
|
(tag.social ["group override set" "tile"])
|
2024-10-15 23:06:31 +00:00
|
|
|
(tag.steam ["suppressevent activate activatefocus" "workspace special:steam"])
|
2024-09-11 23:16:44 +00:00
|
|
|
(tag.terminal ["tile"])
|
|
|
|
(tag.vm ["workspace special:vm"])
|
|
|
|
(tag.wine ["noborder" "noshadow"])
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
### Overrides
|
2024-12-02 19:43:33 +00:00
|
|
|
(class "dev\\.benz\\.walker" ["noanim" "noshadow" "pin" "stayfocused"]) # Imitate layer
|
2024-11-08 20:34:18 +00:00
|
|
|
(class "org\\.gnome\\.NautilusPreviewer" ["stayfocused"]) # Sushi
|
2024-10-26 18:16:03 +00:00
|
|
|
(class "signal" ["group override new" "tile"]) # Initial window in social group
|
2024-09-11 23:16:44 +00:00
|
|
|
(class "steam_app_1473350" ["workspace 0"]) # (the) Gnorp Apologue
|
2024-10-26 17:15:29 +00:00
|
|
|
(class "Tap Wizard 2\\.x86_64" ["workspace 0"])
|
2024-09-26 02:34:20 +00:00
|
|
|
(class "Xdg-desktop-portal-gtk" ["noborder" "noshadow"])
|
2024-11-25 15:08:04 +00:00
|
|
|
(title "File Upload" ["center" "float" "size 1000 625"])
|
2024-11-24 19:12:48 +00:00
|
|
|
(title "Open" ["center" "float" "size 1000 625"])
|
|
|
|
(title "Save As" ["center" "float" "size 1000 625"])
|
2024-09-11 23:16:44 +00:00
|
|
|
|
2024-09-09 00:22:14 +00:00
|
|
|
#!! Expressions are not wrapped in ^$
|
|
|
|
(fields {
|
2024-09-11 23:16:44 +00:00
|
|
|
class = "^com\\.github\\.wwmm\\.easyeffects$";
|
|
|
|
title = "^Easy Effects$"; # Main window
|
2024-11-17 20:14:23 +00:00
|
|
|
} ["center" "float" "size 50% 50%"])
|
2024-09-09 00:22:14 +00:00
|
|
|
(fields {
|
2024-09-11 23:16:44 +00:00
|
|
|
class = "^discord$";
|
|
|
|
title = "^Discord Updater$"; # Update dialog
|
|
|
|
} ["float" "nofocus"])
|
|
|
|
(fields {
|
|
|
|
class = "^lutris$";
|
|
|
|
title = "^Lutris$"; # Main window
|
2024-11-17 20:14:23 +00:00
|
|
|
} ["center" "float" "size 1000 500"])
|
2024-11-08 21:58:57 +00:00
|
|
|
(fields {
|
|
|
|
class = "^org\\.gnome\\.Loupe$";
|
|
|
|
title = "^wallpaper.png$";
|
|
|
|
} ["tile" "workspace special:wallpaper"])
|
2024-11-24 19:12:48 +00:00
|
|
|
(fields {
|
|
|
|
class = "^org\\.gnome\\.Nautilus$";
|
|
|
|
title = "^Home$"; # Main window
|
|
|
|
} ["size 1000 625"])
|
2024-10-04 18:25:48 +00:00
|
|
|
(fields {
|
|
|
|
class = "^org\\.remmina\\.Remmina$";
|
2024-11-17 20:14:23 +00:00
|
|
|
title = "^Remmina.*$"; # Main windows
|
|
|
|
} ["center" "float" "size 1000 500"])
|
2024-09-11 23:16:44 +00:00
|
|
|
(fields {
|
|
|
|
class = "^steam$";
|
|
|
|
title = "^notificationtoasts$"; # Steam notifications
|
2024-11-17 20:14:23 +00:00
|
|
|
} ["float" "nofocus" "pin"])
|
2024-09-11 23:16:44 +00:00
|
|
|
(fields {
|
|
|
|
class = "^steam$";
|
|
|
|
title = "^Steam$"; # Main window
|
|
|
|
} ["tile"])
|
2024-09-09 00:22:14 +00:00
|
|
|
(fields {
|
|
|
|
class = "^virt-manager$";
|
2024-09-11 23:16:44 +00:00
|
|
|
title = "^.+on QEMU/KVM$"; # VM window
|
2024-10-26 17:15:29 +00:00
|
|
|
} ["group override set" "tile"])
|
2024-09-09 00:22:14 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|