nix/lib/modules/wayland.nix
2023-12-11 10:06:57 +00:00

298 lines
8.5 KiB
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ user }: { lib, pkgs, config, ... }:
with lib;
let
cfg = config.windowManager;
in
{
options.windowManager = {
hyprland = mkEnableOption "hyprland";
sway = mkEnableOption "sway";
};
config = mkIf (cfg.sway || cfg.hyprland) {
services.greetd = {
enable = true;
settings = rec {
hypr_session = {
command = "Hyprland";
user = user;
};
sway_session = {
command = "sway";
user = user;
};
default_session = if cfg.sway then sway_session else hypr_session;
};
};
home-manager.users.${user}.imports = [{
wayland.windowManager.hyprland = mkIf cfg.hyprland {
enable = true;
systemdIntegration = true;
# https://wiki.hyprland.org/Configuring/Variables/
extraConfig = ''
# === GLOBAL CONFIG ===
env = GDK_BACKEND,wayland,x11
env = QT_QPA_PLATFORM,wayland;xcb
env = SDL_VIDEODRIVER,wayland
env = CLUTTER_BACKEND,wayland
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland
env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
env = NIXOS_OZONE_WL,1
input {
touchpad {
natural_scroll = yes
scroll_factor = 0.5
}
}
bind = SUPER_SHIFT, X, killactive,
bind = SUPER_SHIFT, E, exit,
bind = SUPER, SLASH, focuswindow, brave-browser
bind = SUPER, n, focuswindow, Logseq
windowrule = float, title:wlogout
windowrule = idleinhibit always, vrmonitor
windowrule = idleinhibit focus, steam_app
bind = SUPER, h, movefocus,l
bind = SUPER, l, movefocus,r
bindm = SUPER, mouse:272, movewindow
bindm = SUPER, mouse:273, resizewindow
bind = SUPER, j, layoutmsg,cyclenext
bind = SUPER, k, layoutmsg,cycleprev
bind = SUPER, space, layoutmsg,swapwithmaster master
bind = SUPER, F, fullscreen,
bind = SUPER, V, togglefloating,
bind = SUPER, W, layoutmsg, orientationprev
bind = SUPER_SHIFT, W, layoutmsg, orientationnext
bind = SUPER_SHIFT, V, togglegroup,
bind = SUPER_SHIFT, h, changegroupactive,b
bind = SUPER_SHIFT, h, moveintogroup,l
bind = SUPER_SHIFT, l, moveintogroup,r
bind = SUPER_SHIFT, l, changegroupactive,f
bind = SUPER, Y, togglespecialworkspace
bind = SUPER_SHIFT, Y, movetoworkspace, special
bind = SUPER, R, submap, resize
submap = resize
binde=,right,resizeactive,10 0
binde=,left,resizeactive,-10 0
binde=,up,resizeactive,0 -10
binde=,down,resizeactive,0 10
binde=,k,resizeactive,0 -10
binde=,j,resizeactive,0 10
binde=,l,splitratio,0.05
binde=,h,splitratio,-0.05
binde=SHIFT,l,splitratio,0.3
binde=SHIFT,h,splitratio,-0.3
bind = , escape, submap,reset
bind = , enter, submap,reset
bind = SUPER, R, submap,reset
bind = CONTROL, C, submap,reset
submap = reset
workspace = 11, default:true
bind = SUPER,1,workspace,1
bind = SUPER,2,workspace,2
bind = SUPER,3,workspace,3
bind = SUPER,4,workspace,4
bind = SUPER,5,workspace,5
bind = SUPER,6,workspace,6
bind = SUPER,7,workspace,7
bind = SUPER,8,workspace,8
bind = SUPER,9,workspace,9
bind = SUPER,0,workspace,10
bind = SUPER,left,workspace,r-1
bind = SUPER,right,workspace,r+1
bind = SUPER_SHIFT,1,movetoworkspace,1
bind = SUPER_SHIFT,2,movetoworkspace,2
bind = SUPER_SHIFT,3,movetoworkspace,3
bind = SUPER_SHIFT,4,movetoworkspace,4
bind = SUPER_SHIFT,5,movetoworkspace,5
bind = SUPER_SHIFT,6,movetoworkspace,6
bind = SUPER_SHIFT,7,movetoworkspace,7
bind = SUPER_SHIFT,8,movetoworkspace,8
bind = SUPER_SHIFT,9,movetoworkspace,9
bind = SUPER_SHIFT,0,movetoworkspace,10
gestures {
workspace_swipe = yes
workspace_swipe_numbered = yes
}
decoration {
rounding = 5
drop_shadow = no
}
bezier = overshot, 0.05, 0.9, 0.1, 1.1
bezier = linear, 0.0, 0.0, 1.0, 1.0
animations {
enabled = 1
animation = windows, 1, 1, default, popin
animation = border, 1, 1, default
animation = fade, 1, 1, default
animation = workspaces, 1, 3, overshot
animation = borderangle,1, 50, linear, loop
}
general {
gaps_out = 10
resize_on_border = yes
layout = master
col.active_border = rgb(FFFF00) rgb(00FFFF) rgb(FF00FF)
border_size = 5
}
master {
mfact = 0.7
new_on_top = yes
}
misc {
vrr = 2
focus_on_activate = yes
}
'';
};
wayland.windowManager.sway = mkIf cfg.sway {
enable = true;
};
programs.swaylock = {
enable = true;
package = pkgs.swaylock-effects;
settings = {
clock = true;
screenshots = true;
effect-scale = 0.5;
effect-blur = "10x10";
grace = 5;
};
};
services.swayidle = {
enable = true;
systemdTarget = "graphical-session.target";
events = [
{ event = "before-sleep"; command = "${pkgs.swaylock-effects}/bin/swaylock"; }
{ event = "lock"; command = "${pkgs.swaylock-effects}/bin/swaylock"; }
];
timeouts = [
{
timeout = 300;
command = "${pkgs.swaylock-effects}/bin/swaylock -f";
}
{
timeout = 600;
command = "systemctl suspend";
}
];
};
services.mako = {
enable = true;
};
programs.waybar = {
enable = true;
settings = {
mainBar = {
layer = "top";
position = "top";
height = 36;
modules-left = [ "hyprland/workspaces" "hyprland/window" ];
modules-right = [ "mpris" "pulseaudio" "clock" "tray" "battery" ];
clock = {
format = "📅 {:%a %b-%d %I:%M %p}";
};
pulseaudio = {
format-muted = "🔇 {volume}";
format = "{icon} {volume}";
format-icons.default = [ "🔈" "🔉" "🔊" ];
on-click = "${pkgs.pavucontrol}/bin/pavucontrol";
};
mpris = {
format = "{player_icon} {artist} - {title}";
format-paused = "{status_icon} {artist} - {title}";
player-icons = {
default = "";
mpd = "🎵";
};
status-icons = {
paused = "";
};
};
battery = {
format = "{icon} {capacity}%";
format-icons = [ "🤏" "🪫" "🔋" "🔋" ];
states = {
warning = 30;
critical = 15;
};
};
};
};
systemd = {
enable = true;
target = "graphical-session.target";
};
style = ''
* {
min-height: 0;
}
window#waybar {
font-size: small;
background: rgba(0,0,0,0.8);
}
#workspaces button {
border-radius: 1rem;
padding: 0px .5rem;
margin: 0px .5rem 0px 0px;
}
#workspaces button.active {
background: rgba(255,255,255,0.8);
padding: 0px 1rem;
color: black;
}
#workspaces button.inactive:hover {
background: rgba(255,255,255,0.4);
color: black;
}
.modules-right widget label {
padding: 0 1rem;
margin: 0 .5rem;
}
#tray {
min-width: 5rem;
}
'';
};
}];
};
}