Desktop environment refactor
This commit is contained in:
153
modules/desktop/wm/hyprland.nix
Normal file
153
modules/desktop/wm/hyprland.nix
Normal file
@@ -0,0 +1,153 @@
|
||||
{ inputs, config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.samfelag.modules.desktop.wm.hyprland;
|
||||
mod = "Mod4";
|
||||
in {
|
||||
|
||||
options.samfelag.modules.desktop.wm.hyprland = with lib; {
|
||||
enable = mkEnableOption "hyprland window manager";
|
||||
|
||||
mod = my.mkOpt' types.str "Mod4" "Main modifier key for hyprland";
|
||||
|
||||
kb_layout = my.mkOpt' types.str "es" "Keyboard layout(s) for hyprland";
|
||||
|
||||
extraKeybindings = my.mkOpt (types.listOf types.str) [ ];
|
||||
# extraStartup = my.mkOpt (types.listOf types.attrs) [ ];
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
];
|
||||
|
||||
# - Configuration -----------------------------
|
||||
|
||||
# Hyprland config
|
||||
programs.hyprland = {
|
||||
enable = true;
|
||||
xwayland.enable = true;
|
||||
};
|
||||
|
||||
hm.wayland.windowManager.hyprland = {
|
||||
enable = true;
|
||||
xwayland.enable = true;
|
||||
|
||||
package = pkgs.hyprland;
|
||||
# Optional
|
||||
# Whether to enable hyprland-session.target on hyprland startup
|
||||
systemd.enable = true;
|
||||
|
||||
plugins = [
|
||||
pkgs.hyprlandPlugins.hy3
|
||||
];
|
||||
|
||||
settings = {
|
||||
|
||||
general = {
|
||||
layout = "hy3";
|
||||
};
|
||||
|
||||
env = [
|
||||
"HYPRCURSOR_THEME,rose-pine-hyprcursor"
|
||||
"HYPRCURSOR_SIZE,24"
|
||||
];
|
||||
|
||||
input = {
|
||||
kb_layout = cfg.kb_layout;
|
||||
};
|
||||
|
||||
monitor = ",highres,auto,1";
|
||||
|
||||
exec-once = [
|
||||
"hyprpaper"
|
||||
"eww open top-bar"
|
||||
];
|
||||
|
||||
decoration = {
|
||||
rounding = 10;
|
||||
};
|
||||
|
||||
gestures = {
|
||||
# See https://wiki.hyprland.org/Configuring/Variables/ for more
|
||||
workspace_swipe = true;
|
||||
};
|
||||
|
||||
bind = [
|
||||
|
||||
"${cfg.mod}, Q, killactive,"
|
||||
|
||||
"${cfg.mod}, F, fullscreen, 1"
|
||||
"${cfg.mod} SHIFT, F, fullscreen, 0"
|
||||
|
||||
"${cfg.mod} SHIFT, SPACE, togglefloating"
|
||||
|
||||
# Move focus
|
||||
"${cfg.mod}, left, hy3:movefocus, l"
|
||||
"${cfg.mod}, right, hy3:movefocus, r"
|
||||
"${cfg.mod}, up, hy3:movefocus, u"
|
||||
"${cfg.mod}, down, hy3:movefocus, d"
|
||||
|
||||
"${cfg.mod}, h, hy3:movefocus, l"
|
||||
"${cfg.mod}, l, hy3:movefocus, r"
|
||||
"${cfg.mod}, k, hy3:movefocus, u"
|
||||
"${cfg.mod}, j, hy3:movefocus, d"
|
||||
|
||||
# Move focus
|
||||
"${cfg.mod} SHIFT, left, hy3:movewindow, l"
|
||||
"${cfg.mod} SHIFT, right, hy3:movewindow, r"
|
||||
"${cfg.mod} SHIFT, up, hy3:movewindow, u"
|
||||
"${cfg.mod} SHIFT, down, hy3:movewindow, d"
|
||||
|
||||
"${cfg.mod} SHIFT, h, hy3:movewindow, l"
|
||||
"${cfg.mod} SHIFT, l, hy3:movewindow, r"
|
||||
"${cfg.mod} SHIFT, k, hy3:movewindow, u"
|
||||
"${cfg.mod} SHIFT, j, hy3:movewindow, d"
|
||||
|
||||
# Switch workspace
|
||||
"${cfg.mod}, 1, workspace, 1"
|
||||
"${cfg.mod}, 2, workspace, 2"
|
||||
"${cfg.mod}, 3, workspace, 3"
|
||||
"${cfg.mod}, 4, workspace, 4"
|
||||
"${cfg.mod}, 5, workspace, 5"
|
||||
"${cfg.mod}, 0, workspace, 6"
|
||||
|
||||
# Move to workspace
|
||||
"${cfg.mod} SHIFT, 1, movetoworkspace, 1"
|
||||
"${cfg.mod} SHIFT, 2, movetoworkspace, 2"
|
||||
"${cfg.mod} SHIFT, 3, movetoworkspace, 3"
|
||||
"${cfg.mod} SHIFT, 4, movetoworkspace, 4"
|
||||
"${cfg.mod} SHIFT, 5, movetoworkspace, 5"
|
||||
"${cfg.mod} SHIFT, 0, movetoworkspace, 6"
|
||||
|
||||
# - Media ------------------------------
|
||||
|
||||
# Pulse Audio controls (mute)
|
||||
", XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle"
|
||||
|
||||
# Media player controls
|
||||
", XF86AudioPlay, exec, playerctl play-pause"
|
||||
", XF86AudioPause, exec, playerctl play-pause"
|
||||
", XF86AudioNext, exec, playerctl next"
|
||||
", XF86AudioPrev, exec, playerctl previous"
|
||||
", XF86AudioStop, exec, playerctl stop"
|
||||
|
||||
# - Keyboard ---------------------------
|
||||
"${cfg.mod}, Escape, exec, hyprctl switchxkblayout current next"
|
||||
|
||||
] ++ cfg.extraKeybindings;
|
||||
|
||||
binde = [
|
||||
# Pulse Audio controls (volume)
|
||||
", XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5%"
|
||||
", XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5%"
|
||||
];
|
||||
|
||||
bindm = [
|
||||
"${cfg.mod}, mouse:272, hy3:movewindow"
|
||||
"${cfg.mod} SHIFT, mouse:272, resizewindow 1"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
248
modules/desktop/wm/i3.nix
Normal file
248
modules/desktop/wm/i3.nix
Normal file
@@ -0,0 +1,248 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.samfelag.modules.desktop.wm.i3;
|
||||
mod = "Mod4";
|
||||
in {
|
||||
|
||||
options.samfelag.modules.desktop.wm.i3 = with lib; {
|
||||
enable = mkEnableOption "i3 window manager";
|
||||
|
||||
mod = my.mkOpt' types.str "Mod4" "Main modifier key for i3";
|
||||
|
||||
laptop = mkEnableOption "Enable features for a laptop (trackpad, battery, etc...)";
|
||||
|
||||
extraKeybindings = my.mkOpt (types.attrsOf types.str) {};
|
||||
extraStartup = my.mkOpt (types.listOf types.attrs) [ ];
|
||||
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
# - Dependencies -----------------------------
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
playerctl
|
||||
i3lock-blur
|
||||
feh
|
||||
];
|
||||
|
||||
samfelag.modules.desktop.tools.polybar.enable = true;
|
||||
|
||||
fonts.packages = with pkgs; [
|
||||
iosevka
|
||||
(nerdfonts.override { fonts = [ "Iosevka" ]; })
|
||||
];
|
||||
|
||||
services.xserver = {
|
||||
enable = true;
|
||||
|
||||
libinput = lib.mkIf cfg.laptop {
|
||||
enable = true;
|
||||
touchpad.tapping = true;
|
||||
};
|
||||
|
||||
desktopManager = {
|
||||
xterm.enable = false;
|
||||
};
|
||||
|
||||
displayManager = {
|
||||
defaultSession = "none+i3";
|
||||
lightdm = {
|
||||
enable = true;
|
||||
greeters.mini = {
|
||||
enable = true;
|
||||
user = "marc";
|
||||
extraConfig = ''
|
||||
[greeter]
|
||||
show-sys-info = true
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
windowManager.i3.enable = true;
|
||||
windowManager.i3.package = pkgs.i3-gaps;
|
||||
};
|
||||
|
||||
# - Configuration ----------------------------
|
||||
|
||||
hm.xsession.windowManager.i3 = {
|
||||
enable = true;
|
||||
|
||||
config = {
|
||||
modifier = mod;
|
||||
|
||||
fonts = {
|
||||
names = ["DejaVu Sans Mono" "Iosevka Nerd Font"];
|
||||
style = "regular";
|
||||
size = 12.0;
|
||||
};
|
||||
|
||||
focus.followMouse = false;
|
||||
|
||||
bars = [ ];
|
||||
|
||||
window = {
|
||||
border = 1;
|
||||
titlebar = false;
|
||||
|
||||
commands = [
|
||||
{
|
||||
# Allow floating terminals
|
||||
command = "floating enable";
|
||||
criteria = { title="^floating-term$"; };
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
gaps = {
|
||||
inner = 10;
|
||||
outer = 0;
|
||||
};
|
||||
|
||||
startup = [
|
||||
{ command = "i3-msg workspace 1"; }
|
||||
] ++ cfg.extraStartup;
|
||||
|
||||
modes = {
|
||||
"resize" = {
|
||||
"h" = "resize shrink width 10 px or 10 ppt";
|
||||
"j" = "resize grow height 10 px or 10 ppt";
|
||||
"k" = "resize shrink height 10 px or 10 ppt";
|
||||
"l" = "resize grow width 10 px or 10 ppt";
|
||||
|
||||
"Left" = "resize shrink width 10 px or 10 ppt";
|
||||
"Down" = "resize grow height 10 px or 10 ppt";
|
||||
"Up" = "resize shrink height 10 px or 10 ppt";
|
||||
"Right" = "resize grow width 10 px or 10 ppt";
|
||||
|
||||
"Return" = "mode \"default\"";
|
||||
"Escape" = "mode \"default\"";
|
||||
};
|
||||
};
|
||||
|
||||
keybindings = {
|
||||
"${mod}+q" = "kill";
|
||||
|
||||
# Focus
|
||||
"${mod}+h" = "focus left";
|
||||
"${mod}+j" = "focus down";
|
||||
"${mod}+k" = "focus up";
|
||||
"${mod}+l" = "focus right";
|
||||
"${mod}+Left" = "focus left";
|
||||
"${mod}+Down" = "focus down";
|
||||
"${mod}+Up" = "focus up";
|
||||
"${mod}+Right" = "focus right";
|
||||
|
||||
# Move
|
||||
"${mod}+Shift+h" = "move left";
|
||||
"${mod}+Shift+j" = "move down";
|
||||
"${mod}+Shift+k" = "move up";
|
||||
"${mod}+Shift+l" = "move right";
|
||||
"${mod}+Shift+Left" = "move left";
|
||||
"${mod}+Shift+Down" = "move down";
|
||||
"${mod}+Shift+Up" = "move up";
|
||||
"${mod}+Shift+Right" = "move right";
|
||||
|
||||
# split orientation
|
||||
"${mod}+z" = "split h;exec notify-send 'tile horizontally'";
|
||||
"${mod}+v" = "split v;exec notify-send 'tile vertically'";
|
||||
|
||||
# enter fullscreen mode for the focused container
|
||||
"${mod}+f" = "fullscreen toggle";
|
||||
|
||||
# change container layout (stacked, tabbed, toggle split)
|
||||
"${mod}+s" = "layout stacking";
|
||||
"${mod}+w" = "layout tabbed";
|
||||
"${mod}+e" = "layout toggle split";
|
||||
|
||||
# toggle tiling / floating
|
||||
"${mod}+Shift+space" = "floating toggle";
|
||||
|
||||
# focus the parent container
|
||||
"${mod}+a" = "focus parent";
|
||||
|
||||
# Reload config + restart i3
|
||||
"${mod}+Shift+c" = "reload";
|
||||
"${mod}+Shift+r" = "restart";
|
||||
|
||||
# - Modes ------------------------------
|
||||
"${mod}+r" = "mode \"resize\"";
|
||||
|
||||
# - Media ------------------------------
|
||||
|
||||
# Pulse Audio controls
|
||||
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%";
|
||||
"XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%";
|
||||
"Shift+XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +1%";
|
||||
"Shift+XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1%";
|
||||
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle";
|
||||
|
||||
# Media player controls
|
||||
"XF86AudioPlay" = "exec playerctl play-pause";
|
||||
"XF86AudioPause" = "exec playerctl play-pause";
|
||||
"XF86AudioNext" = "exec playerctl next";
|
||||
"XF86AudioPrev" = "exec playerctl previous";
|
||||
"XF86AudioStop" = "exec playerctl stop";
|
||||
|
||||
# - Workspaces -------------------------
|
||||
"${mod}+1" = "workspace 1";
|
||||
"${mod}+2" = "workspace 2";
|
||||
"${mod}+3" = "workspace 3";
|
||||
"${mod}+4" = "workspace 4";
|
||||
"${mod}+5" = "workspace 5";
|
||||
"${mod}+6" = "workspace 6";
|
||||
"${mod}+7" = "workspace 7";
|
||||
"${mod}+8" = "workspace 8";
|
||||
"${mod}+9" = "workspace 9";
|
||||
"${mod}+0" = "workspace 10";
|
||||
|
||||
"${mod}+Shift+1" = "move container to workspace 1; workspace 1";
|
||||
"${mod}+Shift+2" = "move container to workspace 2; workspace 2";
|
||||
"${mod}+Shift+3" = "move container to workspace 3; workspace 3";
|
||||
"${mod}+Shift+4" = "move container to workspace 4; workspace 4";
|
||||
"${mod}+Shift+5" = "move container to workspace 5; workspace 5";
|
||||
"${mod}+Shift+6" = "move container to workspace 6; workspace 6";
|
||||
"${mod}+Shift+7" = "move container to workspace 7; workspace 7";
|
||||
"${mod}+Shift+8" = "move container to workspace 8; workspace 8";
|
||||
"${mod}+Shift+9" = "move container to workspace 9; workspace 9";
|
||||
"${mod}+Shift+0" = "move container to workspace 10; workspace 10";
|
||||
} // cfg.extraKeybindings;
|
||||
|
||||
# - Themeing ---------------------------------
|
||||
colors = {
|
||||
background = "#${config.colorScheme.palette.base00}";
|
||||
focused = {
|
||||
border = "#${config.colorScheme.palette.base03}";
|
||||
background = "#${config.colorScheme.palette.base0B}";
|
||||
text = "#${config.colorScheme.palette.base03}";
|
||||
indicator = "#${config.colorScheme.palette.base04}";
|
||||
childBorder = "#${config.colorScheme.palette.base03}";
|
||||
};
|
||||
focusedInactive = {
|
||||
border = "#${config.colorScheme.palette.base03}";
|
||||
background = "#${config.colorScheme.palette.base04}";
|
||||
text = "#${config.colorScheme.palette.base03}";
|
||||
indicator = "#${config.colorScheme.palette.base04}";
|
||||
childBorder = "#${config.colorScheme.palette.base03}";
|
||||
};
|
||||
unfocused = {
|
||||
border = "#${config.colorScheme.palette.base02}";
|
||||
background = "#${config.colorScheme.palette.base01}";
|
||||
text = "#${config.colorScheme.palette.base03}";
|
||||
indicator = "#${config.colorScheme.palette.base03}";
|
||||
childBorder = "#${config.colorScheme.palette.base02}";
|
||||
};
|
||||
urgent = {
|
||||
border = "#${config.colorScheme.palette.base02}";
|
||||
background = "#${config.colorScheme.palette.base0A}";
|
||||
text = "#${config.colorScheme.palette.base02}";
|
||||
indicator = "#${config.colorScheme.palette.base03}";
|
||||
childBorder = "#${config.colorScheme.palette.base02}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user