diff --git a/home/modules/gui/default.nix b/home/modules/gui/default.nix index 3869944..ad61a54 100644 --- a/home/modules/gui/default.nix +++ b/home/modules/gui/default.nix @@ -84,6 +84,7 @@ in { ./startx.nix ./picom.nix ./theme.nix + ./sway.nix ]; config = let diff --git a/home/modules/gui/sway.nix b/home/modules/gui/sway.nix new file mode 100644 index 0000000..1d9e0e7 --- /dev/null +++ b/home/modules/gui/sway.nix @@ -0,0 +1,109 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.local.gui; +in { + config = mkIf cfg.enable { + home.packages = [ + pkgs.wlr-randr + ]; + + programs = { + waybar.enable = true; + + wofi.enable = true; + }; + + services = { + swayidle = { + enable = true; + + timeouts = [ + { + timeout = 600; + command = "${getExe pkgs.gtklock} -d"; + } + ]; + }; + }; + + systemd.user.services.wl-gammarelay-rs = { + Unit.After = ["sway-session.target"]; + Install.WantedBy = ["sway-session.target"]; + + Service.ExecStart = getExe pkgs.wl-gammarelay-rs; + }; + + wayland.windowManager.sway = { + enable = true; + + config = { + modifier = "Mod4"; + focus.followMouse = true; + + fonts = { + size = 11.0; + names = ["DejaVu Sans Mono"]; + style = "Bold Semi-Condensed"; + }; + + bars = singleton { + command = "waybar"; + position = "top"; + }; + + keybindings = let + mod = config.wayland.windowManager.sway.config.modifier; + wofi = config.programs.wofi.package; + + grimshot = getExe pkgs.sway-contrib.grimshot; + in + mkOptionDefault { + "${mod}+a" = "focus parent"; + "${mod}+c" = "focus child"; + "${mod}+d" = "exec --no-startup-id ${getExe wofi} -S run"; + "${mod}+i" = "exec busctl --user call rs.wl-gammarelay / rs.wl.gammarelay ToggleInverted"; + "${mod}+o" = "exec ${getExe pkgs.gtklock} -d"; + "${mod}+Return" = "exec ${lib.getExe pkgs.kitty} ${lib.getExe pkgs.tmux}"; + "${mod}+Shift+e" = "input * xkb_layout latam"; + "${mod}+Shift+u" = "input * xkb_layout us"; + "${mod}+p" = "exec ${grimshot} copy active"; + "${mod}+Shift+p" = "exec ${grimshot} copy area"; + "${mod}+Ctrl+p" = "exec ${grimshot} copy window"; + }; + + window.commands = [ + # (No) Title Bars + { + command = "border pixel 5"; + criteria.class = "^.*"; + } + + { + command = "floating enabled"; + criteria.class = "floating"; + } + ]; + }; + + extraSessionCommands = '' + export SDL_VIDEODRIVER=wayland + # needs qt5.qtwayland in systemPackages + export QT_QPA_PLATFORM=wayland + export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" + # Fix for some Java AWT applications (e.g. Android Studio), + # use this if they aren't displayed properly: + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; + + swaynag.enable = true; + systemd.enable = true; + + xwayland = true; + }; + }; +} diff --git a/sys/modules/default.nix b/sys/modules/default.nix index 27d719e..842c05a 100644 --- a/sys/modules/default.nix +++ b/sys/modules/default.nix @@ -15,5 +15,6 @@ ./bluetooth.nix ./net.nix ./steam.nix + ./xdg.nix ]; } diff --git a/sys/modules/xdg.nix b/sys/modules/xdg.nix new file mode 100644 index 0000000..f9d9c54 --- /dev/null +++ b/sys/modules/xdg.nix @@ -0,0 +1,32 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.local.sys.xdg; +in { + options.local.sys.xdg = { + enable = mkEnableOption "xdg settings"; + }; + config = mkIf cfg.enable { + xdg.portal = { + enable = true; + wlr.enable = true; + extraPortals = [pkgs.xdg-desktop-portal-gtk]; + xdgOpenUsePortal = true; + # warning: xdg-desktop-portal 1.17 reworked how portal implementations are loaded, you + # should either set `xdg.portal.config` or `xdg.portal.configPackages` + # to specify which portal backend to use for the requested interface. + # + # https://github.com/flatpak/xdg-desktop-portal/blob/1.18.1/doc/portals.conf.rst.in + # + # If you simply want to keep the behaviour in < 1.17, which uses the first + # portal implementation found in lexicographical order, use the following: + # + # xdg.portal.config.common.default = "*"; + config.common.default = "*"; + }; + }; +} diff --git a/sys/platforms/posixlycorrect/default.nix b/sys/platforms/posixlycorrect/default.nix index 7c348b8..ece541d 100644 --- a/sys/platforms/posixlycorrect/default.nix +++ b/sys/platforms/posixlycorrect/default.nix @@ -20,6 +20,7 @@ virtualisation.enable = true; androidSupport.enable = true; steam.enable = true; + xdg.enable = true; users = { fabian = {