diff --git a/modules/home/services/screen-locker/default.nix b/modules/home/services/screen-locker/default.nix new file mode 100644 index 0000000..9d1e4a6 --- /dev/null +++ b/modules/home/services/screen-locker/default.nix @@ -0,0 +1,28 @@ +{ + lib, + config, + pkgs, + + ... +}: +let + inherit (lib) mkEnableOption mkIf; + + cfg = config.marleyos.services.screen-locker; + hasXorg = config.xsession.enable; + hasI3 = config.xsession.windowManager.i3.enable; +in +{ + options.marleyos.services.screen-locker.enable = mkEnableOption "screen-locker"; + + config = mkIf (cfg.enable && hasXorg) { + services.screen-locker = { + enable = true; + inactiveInterval = 20; + + # exec xss-lock {xss-lock.extraOptions} -- {lockCmd} + xss-lock.extraOptions = [ "--transfer-sleep-lock" ]; + lockCmd = if hasI3 then "${pkgs.i3lock}/bin/i3lock --nofork" else ""; + }; + }; +} diff --git a/modules/home/xorg/i3/bg.jpg b/modules/home/xorg/i3/bg.jpg new file mode 100644 index 0000000..2cd8b70 Binary files /dev/null and b/modules/home/xorg/i3/bg.jpg differ diff --git a/modules/home/xorg/i3/default.nix b/modules/home/xorg/i3/default.nix index b62e3f1..28bd604 100644 --- a/modules/home/xorg/i3/default.nix +++ b/modules/home/xorg/i3/default.nix @@ -1,10 +1,19 @@ { lib, config, + pkgs, ... }: let - inherit (lib) mkEnableOption mkIf; + inherit (lib) + mkEnableOption + mkIf + concatMapAttrs + map + range + listToAttrs + getExe + ; inherit (lib.marleyos) enabled; cfg = config.marleyos.xorg.i3; @@ -16,10 +25,151 @@ in marleyos = { programs.rofi = enabled; services = { + dunst = enabled; picom = enabled; polybar = enabled; - dunst = enabled; + screen-locker = enabled; }; }; + + home.packages = with pkgs; [ + networkmanagerapplet + feh + ]; + + xsession.windowManager.i3 = { + enable = true; + package = config.lib.nixGL.wrap pkgs.i3; + + extraConfig = "tiling_drag modifier titlebar"; + + config = + let + directions = { + left = "h"; + down = "j"; + up = "k"; + right = "l"; + }; + in + { + focus.followMouse = false; + window.border = 0; + floating.border = 0; + + window.titlebar = false; + + gaps = { + smartBorders = "no_gaps"; + inner = 10; + top = 50; + }; + + bars = [ ]; + + # Startup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + startup = with pkgs; [ + { command = "${getExe feh} --no-fehbg --bg-fill ${./bg.jpg}"; } + { command = "${getExe networkmanagerapplet}"; } + ]; + + # Keybindings - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + modifier = "Mod4"; + + keybindings = + let + mod = config.xsession.windowManager.i3.config.modifier; + workspaces = range 1 10; + getI = i: if i == 10 then "0" else toString i; + inherit (config.xdg) configHome; + isGenericLinux = config.targets.genericLinux.enable; + in + { + "${mod}+Shift+c" = "reload"; + "${mod}+Shift+r" = "restart"; + "${mod}+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'"; + + "${mod}+e" = "layout toggle split"; + "${mod}+Control+h" = "split -"; + "${mod}+Control+v" = "split |"; + + "${mod}+f" = "fullscreen toggle"; + + "${mod}+Shift+space" = "floating toggle"; + + "${mod}+Control+r" = "mode resize"; + + "${mod}+q" = "kill"; + + "${mod}+r" = "exec ${configHome}/rofi/launchers/type-1/launcher.sh"; + "${mod}+Return" = "exec ${if isGenericLinux then "wezterm" else "${pkgs.wezterm}/bin/wezterm"}"; + } + + # PulseAudio Volume - - - - - - - - - - - - - - - - - - - - - - - - + // (concatMapAttrs + (key: cmd: { + "${key}" = "exec --no-startup-id pactl ${cmd} && killall -SIGUSR1 i3status"; + }) + { + XF86AudioRaiseVolume = "set-sink-volume @DEFAULT_SINK@ +10%"; + XF86AudioLowerVolume = "set-sink-volume @DEFAULT_SINK@ -10%"; + XF86AudioMute = "set-sink-mute @DEFAULT_SINK@ toggle"; + XF86AudioMicMute = "set-source-mute @DEFAULT_SOURCE@ toggle"; + } + ) + + # Focus & Movement - - - - - - - - - - - - - - - - - - - - - - - - - + // (concatMapAttrs (direction: key: { + "${mod}+${key}" = "focus ${direction}"; + "${mod}+Shift+${key}" = "move ${direction}"; + }) directions) + + # Switch Workspaces - - - - - - - - - - - - - - - - - - - - - - - - - + // (listToAttrs ( + (map (i: { + name = "${mod}+${getI i}"; + value = "workspace number ${toString i}"; + })) + workspaces + )) + + # Move Windows Between Workspaces - - - - - - - - - - - - - - - - - - + // (listToAttrs ( + (map (i: { + name = "${mod}+Shift+${getI i}"; + value = "move container to workspace number ${toString i}"; + })) + workspaces + )); + + # Resize Windows - - - - - - - - - - - - - - - - - - - - - - - - - - - + modes.resize = + let + mod = config.xsession.windowManager.i3.config.modifier; + in + { + Return = "mode default"; + Escape = "mode default"; + "${mod}+Control+r" = "mode default"; + } + // (concatMapAttrs + (key: action: { + "${key}" = "resize ${action} 10 px or 10 ppt"; + }) + rec { + Left = "shrink width"; + Down = "shrink height"; + Up = "grow height"; + Right = "grow width"; + "${directions.left}" = Left; + "${directions.down}" = Down; + "${directions.up}" = Up; + "${directions.right}" = Right; + } + ); + }; + }; }; }