From 267a9cecfd291c6f141c35faef6890e04b8adc99 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Tue, 26 Apr 2022 23:48:18 -0400 Subject: [PATCH] Switching from sway -> i3 Wayland as a couple to man issues still. QT related applications being unable to function was the final straw. --- modules/applications/default.nix | 3 +- modules/applications/dunst.nix | 3 +- modules/applications/firefox.nix | 6 +- modules/applications/i3/i3.nix | 132 +++++++++++++++++++++++- modules/applications/kdeconnect.nix | 5 - modules/applications/sway/gammastep.nix | 5 +- modules/applications/sway/sway.nix | 4 +- modules/default.nix | 8 +- 8 files changed, 140 insertions(+), 26 deletions(-) diff --git a/modules/applications/default.nix b/modules/applications/default.nix index 7e7e681..244d586 100644 --- a/modules/applications/default.nix +++ b/modules/applications/default.nix @@ -9,7 +9,8 @@ ./kitty.nix ./nextcloud.nix ./spotify.nix - ./sway + ./i3 + ./sway ]; } diff --git a/modules/applications/dunst.nix b/modules/applications/dunst.nix index 67068bc..6d6887c 100644 --- a/modules/applications/dunst.nix +++ b/modules/applications/dunst.nix @@ -2,11 +2,12 @@ let cfg = config.this.application.dunst; sway = config.this.application.sway; + i3 = config.this.application.i3; graphical = config.this.graphical; in with lib; { options = { this.application.dunst.enable = mkOption { - default = sway.enable; + default = i3.enable || sway.enable; type = with types; bool; }; }; diff --git a/modules/applications/firefox.nix b/modules/applications/firefox.nix index 279e519..c95adc4 100644 --- a/modules/applications/firefox.nix +++ b/modules/applications/firefox.nix @@ -13,11 +13,7 @@ in with lib; { }; config = mkIf cfg.enable { - environment.sessionVariables = { - MOZ_USE_XINPUT2 = "1"; - } // optionals (graphical.protocol == "Wayland") { - MOZ_ENABLE_WAYLAND = "1"; - } // optionals (sway_cfg.enable) { XDG_CURRENT_DESKTOP = "sway"; }; + environment.sessionVariables = { MOZ_USE_XINPUT2 = "1"; }; home-manager.users.james = { programs.firefox = { diff --git a/modules/applications/i3/i3.nix b/modules/applications/i3/i3.nix index 58f978b..1a09cdb 100644 --- a/modules/applications/i3/i3.nix +++ b/modules/applications/i3/i3.nix @@ -17,13 +17,139 @@ in with lib; { }; }; - config = mkif cfg.enable { - this.graphical.protocol = "X11"; + config = mkIf cfg.enable { + programs.dconf.enable = true; + + services.xserver = { + enable = true; + + xkbOptions = "ctrl:nocaps"; + libinput = { + enable = true; + touchpad = { + naturalScrolling = true; + clickMethod = "clickfinger"; + tapping = false; + tappingDragLock = false; + }; + }; + + windowManager.i3 = { + enable = true; + package = pkgs.i3-gaps; + extraPackages = with pkgs; [ + feh + nitrogen + dmenu # application launcher most people use + i3status # gives you the default i3 status bar + i3lock # default i3 screen locker + i3blocks # if you are planning on using i3blocks over i3status + ]; + }; + }; + home-manager.users.james = { xsession.windowManager.i3 = { enable = true; - package = "pkgs.i3-gaps"; + package = pkgs.i3-gaps; + config = { + colors = { + focusedInactive = { + background = "#1E1E2E"; + border = "#1E1E2E"; + childBorder = "#1E1E2E"; + indicator = "#1E1E2E"; + text = "#C9CBFF"; + }; + unfocused = { + background = "#1E1E2E"; + border = "#1E1E2E"; + childBorder = "#1E1E2E"; + indicator = "#1E1E2E"; + text = "#C9CBFF"; + }; + focused = { + background = "#131020"; + border = "#131020"; + childBorder = "#131020"; + indicator = "#131020"; + text = "#ABE9B3"; + }; + urgent = { + background = "#F28FAD"; + border = "#F28FAD"; + childBorder = "#F28FAD"; + indicator = "#F28FAD"; + text = "#ABE9B3"; + }; + }; + fonts = { + names = [ "Alegreya" "FontAwesome" ]; + size = 9.0; + }; + gaps = { + smartBorders = "off"; + smartGaps = true; + inner = 5; + outer = 2; + }; + terminal = "${pkgs.kitty}/bin/kitty"; + keybindings = mkOptionDefault { + "${modifier}+q" = "kill"; + "${modifier}+d" = "focus mode_toggle"; + "${modifier}+a" = "focus parent"; + "${modifier}+shift+s" = "sticky toggle"; + "${modifier}+shift+f" = "floating toggle"; + "${modifier}+space" = + "exec $(${pkgs.dmenu}/bin/dmenu_path | ${pkgs.dmenu}/bin/dmenu)"; + Pause = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + XF86AudioLowerVolume = "exec ${pkgs.volume-sh}/bin/volume.sh down"; + XF86AudioMute = "exec ${pkgs.volume-sh}/bin/volume.sh mute"; + XF86AudioRaiseVolume = "exec ${pkgs.volume-sh}/bin/volume.sh up"; + XF86MonBrightnessDown = + "exec ${pkgs.brightness-sh}/bin/brightness.sh down"; + XF86MonBrightnessUp = + "exec ${pkgs.brightness-sh}/bin/brightness.sh up"; + }; + modifier = "Mod4"; + startup = [ + { command = "${pkgs.autotiling}/bin/autotiling"; } + { command = "${pkgs.feh}/bin/feh --bg-scale ${wallpaper}"; } + ]; + }; }; }; + + systemd.user = { + targets.i3-session = { + description = "i3 compositor session"; + documentation = [ "man:systemd.special(7)" ]; + bindsTo = [ "graphical-session.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + }; + services.i3 = { + enable = true; + description = "i3 - i3 window manager"; + documentation = [ "man:i3(5)" ]; + bindsTo = [ "default.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + environment.PATH = lib.mkForce null; + serviceConfig = { + Type = "simple"; + ExecStart = + "${pkgs.dbus}/bin/dbus-run-session ${pkgs.i3}/bin/i3 --debug"; + ExecStopPost = + "/usr/bin/env systemctl --user unset-environment DISPLAY I3SOCK "; + NotifyAccess = "all"; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; + }; + }; + }; + + users.users.james.extraGroups = [ "video" "audio" ]; }; } diff --git a/modules/applications/kdeconnect.nix b/modules/applications/kdeconnect.nix index 3fe2d42..efb97d2 100644 --- a/modules/applications/kdeconnect.nix +++ b/modules/applications/kdeconnect.nix @@ -11,11 +11,6 @@ in with lib; { }; config = mkIf cfg.enable { - - environment.sessionVariables = optionals (graphical.protocol == "Wayland") { - QT_QPA_PLATFORM = "wayland"; - QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; - }; # home-manager.users.james = { # services.kdeconnect = { # indicator = true; diff --git a/modules/applications/sway/gammastep.nix b/modules/applications/sway/gammastep.nix index 0bb3adc..769648d 100644 --- a/modules/applications/sway/gammastep.nix +++ b/modules/applications/sway/gammastep.nix @@ -2,10 +2,11 @@ let cfg = config.this.application.gammastep; sway = config.this.application.sway; + i3 = config.this.application.i3; in with lib; { options = { this.application.gammastep.enable = mkOption { - default = sway.enable; + default = i3.enable || sway.enable; type = with types; bool; }; }; @@ -24,7 +25,7 @@ in with lib; { systemd.user.services.gammastep = { enable = true; description = "Nightly color shifting"; - wantedBy = [ "sway-session.target" ]; + wantedBy = [ "sway-session.target" "i3-session.target" ]; partOf = [ "graphical-session.target" ]; serviceConfig = { ExecStart = '' diff --git a/modules/applications/sway/sway.nix b/modules/applications/sway/sway.nix index 4ccece2..24e88f1 100644 --- a/modules/applications/sway/sway.nix +++ b/modules/applications/sway/sway.nix @@ -13,14 +13,12 @@ let in with lib; { options = { this.application.sway.enable = mkOption { - default = graphical.enable; + default = false; type = with types; bool; }; }; config = mkIf cfg.enable { - this.graphical.protocol = "Wayland"; - home-manager.users.james = { home.sessionVariables = { XDG_CURRENT_DESKTOP = "sway"; }; systemd.user.sessionVariables = { XDG_CURRENT_DESKTOP = "sway"; }; diff --git a/modules/default.nix b/modules/default.nix index 80e3cdb..cdc2698 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,12 +3,8 @@ with lib; let in { - options.this.graphical.enable = - mkEnableOption "Does this actually need X/Wayland"; - - options.this.graphical.protocol = mkOption { - type = types.enum [ "X11" "Wayland" ]; - default = null; + options.this.graphical = { + enable = mkEnableOption "Does this actually need X/Wayland"; }; imports = [ ./applications ./lang ./system ];