From c7ff0f5092d72c5c9540a34fa22607d22c2832f0 Mon Sep 17 00:00:00 2001 From: Stefan Ellmauthaler Date: Wed, 10 Aug 2022 14:40:01 +0200 Subject: [PATCH] First phase to swayfy the setup --- machines/stel-xps/default.nix | 2 ++ modules/communication.nix | 2 +- modules/graphical.nix | 9 +++--- modules/sway.nix | 51 +++++++++++++++++++++++++++++++ users/ellmau/default.nix | 8 +++-- users/ellmau/sway.nix | 56 +++++++++++++++++++++++++++++++++++ 6 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 modules/sway.nix create mode 100644 users/ellmau/sway.nix diff --git a/machines/stel-xps/default.nix b/machines/stel-xps/default.nix index 1ebcf26..5de3846 100644 --- a/machines/stel-xps/default.nix +++ b/machines/stel-xps/default.nix @@ -20,6 +20,8 @@ # enable X11 with lightdm and i3 graphical = { enable = true; + sway.enable = true; + i3.enable = false; # set dpi if used in mobile applications # dpi = 180; }; diff --git a/modules/communication.nix b/modules/communication.nix index c8513a8..89c4eb4 100644 --- a/modules/communication.nix +++ b/modules/communication.nix @@ -7,7 +7,7 @@ with lib; { cfg = config.elss.programs.communication; in mkIf cfg.enable { - elss.graphical.enable = true; + # elss.graphical.enable = true; environment.systemPackages = with pkgs; [ element-desktop jitsi-meet-electron diff --git a/modules/graphical.nix b/modules/graphical.nix index 5adb093..2ee6d9d 100644 --- a/modules/graphical.nix +++ b/modules/graphical.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: with lib; { options.elss.graphical = { - enable = mkEnableOption "configure i3-based graphical layer"; + enable = mkEnableOption "configure graphical layer"; greeterCursorsize = mkOption { type = types.int; default = 16; @@ -16,6 +16,7 @@ with lib; { DPI setting for the xserver ''; }; + i3.enable = mkEnableOption "enable i3"; }; config = let @@ -24,11 +25,11 @@ with lib; { #xserverDPI = if config.variables.hostName == "stel-xps" then 180 else null; in mkIf cfg.enable { - elss.users.x11.enable = true; + elss.users.x11.enable = if cfg.i3.enable then true else false; elss.networking.useNetworkManager = true; services = { - xserver = { + xserver = mkIf cfg.i3.enable { enable = true; dpi = cfg.dpi; displayManager.lightdm = { @@ -59,7 +60,7 @@ with lib; { sound.enable = true; hardware = { - pulseaudio.enable = true; + #pulseaudio.enable = true; bluetooth.enable = true; }; diff --git a/modules/sway.nix b/modules/sway.nix new file mode 100644 index 0000000..c5f0865 --- /dev/null +++ b/modules/sway.nix @@ -0,0 +1,51 @@ +{ config, pkgs, lib, ... }: +with lib; { + options.elss.graphical.sway.enable = mkEnableOption "Use sway"; + config = + let + cfg = config.elss.graphical.sway; + in + mkIf cfg.enable { + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; + + # xdg-desktop-portal works by exposing a series of D-Bus interfaces + # known as portals under a well-known name + # (org.freedesktop.portal.Desktop) and object path + # (/org/freedesktop/portal/desktop). + # The portal interfaces include APIs for file access, opening URIs, + # printing and others. + services.dbus.enable = true; + xdg.portal = { + enable = true; + wlr.enable = true; + # gtk portal needed to make gtk apps happy + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + gtkUsePortal = true; + }; + + # enable sway window manager + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + + # greetd login manager + services.greetd = { + enable = true; + package = pkgs.greetd.tuigreet; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd sway"; + }; + }; + }; + + environment.systemPackages = with pkgs; [ + rofi + ]; + }; +} diff --git a/users/ellmau/default.nix b/users/ellmau/default.nix index 5ece8b8..7ee9a11 100644 --- a/users/ellmau/default.nix +++ b/users/ellmau/default.nix @@ -1,14 +1,16 @@ { config, lib, pkgs, ... }: { imports = [ - ./autorandr.nix +# ./autorandr.nix ./dunst.nix ./git.nix ./gpg.nix - ./i3.nix +# ./i3.nix ./nextcloud.nix - ./polybar.nix +# ./polybar.nix ./zsh.nix + + ./sway.nix ]; services = { gnome-keyring = { diff --git a/users/ellmau/sway.nix b/users/ellmau/sway.nix new file mode 100644 index 0000000..075b8a8 --- /dev/null +++ b/users/ellmau/sway.nix @@ -0,0 +1,56 @@ +{ config, pkgs, lib, ... }: +{ + wayland.windowManager.sway = { + enable = true; + config = { + down = "k"; + up = "l"; + left = "j"; + right = "semicolon"; + + modifier = "Mod4"; + + keybindings = + let + modifier = config.wayland.windowManager.sway.config.modifier; + in + lib.mkOptionDefault { + "${modifier}+Shift+q" = "kill"; + "${modifier}+d" = "exec ${pkgs.rofi}/bin/rofi -show drun"; + "${modifier}+Tab" = "exec ${pkgs.rofi}/bin/rofi -show window"; + "${modifier}+BackSpace" = "mode $mode_system"; + }; + keycodebindings = + let + modifier = config.wayland.windowManager.sway.config.modifier; + in + { }; + + startup = [ + { + command = "--no-startup-id nm-applet"; + always = true; + } + + ]; + terminal = "alacritty"; + window = { + titlebar = true; + }; + }; + extraConfig = '' + mode "$mode_system" { + bindsym l exec --no-startup-id $i3lockwall, mode "default" + bindsym Ctrl+e exec --no-startup-id swaymsg exit, mode "default" + #bindsym s exec --no-startup-id $i3lockwall && systemctl suspend, mode "default" + #bindsym h exec --no-startup-id $i3lockwall && systemctl hibernate, mode "default" + bindsym Ctrl+r exec --no-startup-id systemctl reboot, mode "default" + bindsym Ctrl+s exec --no-startup-id systemctl poweroff -i, mode "default" + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" + } + ''; + }; +}