summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/desktops/default.nix2
-rw-r--r--modules/desktops/hyprland/idle.nix1
-rw-r--r--modules/desktops/sway/binds.nix91
-rw-r--r--modules/desktops/sway/config.nix124
-rw-r--r--modules/desktops/sway/default.nix41
-rw-r--r--modules/desktops/sway/idle.nix27
6 files changed, 286 insertions, 0 deletions
diff --git a/modules/desktops/default.nix b/modules/desktops/default.nix
index 37197c2..974ec89 100644
--- a/modules/desktops/default.nix
+++ b/modules/desktops/default.nix
@@ -10,6 +10,7 @@
in {
imports = [
./hyprland
+ ./sway
./wayland.nix
];
@@ -17,6 +18,7 @@ in {
enable = mkEnableOption "Enable baseline desktop utils and programs.";
wayland = mkEnableOption "Enable wayland desktop components.";
hyprland = mkEnableOption "Install the Hyprland desktop.";
+ sway = mkEnableOption "Install the sway desktop.";
};
config = mkIf cfg.enable {
diff --git a/modules/desktops/hyprland/idle.nix b/modules/desktops/hyprland/idle.nix
index 53c447b..d09e665 100644
--- a/modules/desktops/hyprland/idle.nix
+++ b/modules/desktops/hyprland/idle.nix
@@ -2,6 +2,7 @@
home-manager.users.${config.user} = {
services.hypridle = {
enable = config.desktops.hyprland;
+ systemdTarget = "hyprland-session.target";
settings = {
general = {
diff --git a/modules/desktops/sway/binds.nix b/modules/desktops/sway/binds.nix
new file mode 100644
index 0000000..812d446
--- /dev/null
+++ b/modules/desktops/sway/binds.nix
@@ -0,0 +1,91 @@
+{config, ...}: let
+ mod = "Mod4";
+in {
+ home-manager.users.${config.user} = {
+ wayland.windowManager.sway = {
+ config = {
+ keybindings = {
+ # apps
+ "${mod}+Return" = "exec ${config.default.terminal}";
+ "${mod}+l" = "exec ${config.default.lockScreen}";
+ "${mod}+d" = "exec ${config.default.appLauncher}";
+ "${mod}+w" = "exec ${config.default.browser}";
+
+ # exit
+ "${mod}+Shift+l" = "exit";
+ # kill focused window
+ "${mod}+Shift+q" = "kill";
+ # reload sway
+ "${mod}+F5" = "reload";
+
+ # audio
+ "XF86AudioRaiseVolume" = "exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+";
+ "XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
+ "XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
+ "XF86AudioMicMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
+
+ # media
+ "XF86AudioPlay" = "exec playerctl play-pause";
+ "XF86AudioNext" = "exec playerctl next";
+ "XF86AudioPrev" = "exec playerctl previous";
+
+ # backlight
+ "XF86MonBrightnessDown" = "exec brightnessctl set 5%-";
+ "XF86MonBrightnessUp" = "exec brightnessctl set 5%+";
+
+ # screenshot
+ "Print" = "exec grimblast copy area";
+
+ # move focus
+ "${mod}+Left" = "focus left";
+ "${mod}+Down" = "focus down";
+ "${mod}+Up" = "focus up";
+ "${mod}+Right" = "focus right";
+
+ # move focused window
+ "${mod}+Shift+Left" = "move left";
+ "${mod}+Shift+Down" = "move down";
+ "${mod}+Shift+Up" = "move up";
+ "${mod}+Shift+Right" = "move right";
+
+ # switch workspace
+ "${mod}+1" = "workspace number 1";
+ "${mod}+2" = "workspace number 2";
+ "${mod}+3" = "workspace number 3";
+ "${mod}+4" = "workspace number 4";
+ "${mod}+5" = "workspace number 5";
+ "${mod}+6" = "workspace number 6";
+ "${mod}+7" = "workspace number 7";
+ "${mod}+8" = "workspace number 8";
+ "${mod}+9" = "workspace number 9";
+
+ # move focused container to workspace
+ "${mod}+Shift+1" = "move container to workspace number 1";
+ "${mod}+Shift+2" = "move container to workspace number 2";
+ "${mod}+Shift+3" = "move container to workspace number 3";
+ "${mod}+Shift+4" = "move container to workspace number 4";
+ "${mod}+Shift+5" = "move container to workspace number 5";
+ "${mod}+Shift+6" = "move container to workspace number 6";
+ "${mod}+Shift+7" = "move container to workspace number 7";
+ "${mod}+Shift+8" = "move container to workspace number 8";
+ "${mod}+Shift+9" = "move container to workspace number 9";
+
+ # layout
+ "${mod}+Shift+d" = "layout default";
+ "${mod}+Shift+b" = "layout splith";
+ "${mod}+Shift+v" = "layout splitv";
+ "${mod}+Shift+c" = "layout tabbed";
+
+ # fullscreen
+ "${mod}+f" = "fullscreen";
+ # float
+ "${mod}+Shift+space" = "floating toggle";
+ # focus
+ "${mod}+space" = "focus mode_toggle";
+ # parent
+ "${mod}+a" = "focus parent";
+ };
+ };
+ };
+ };
+}
diff --git a/modules/desktops/sway/config.nix b/modules/desktops/sway/config.nix
new file mode 100644
index 0000000..c6c78ca
--- /dev/null
+++ b/modules/desktops/sway/config.nix
@@ -0,0 +1,124 @@
+{config, ...}: {
+ home-manager.users.${config.user} = {
+ wayland.windowManager.sway = {
+ config = {
+ # monitors
+ output =
+ (builtins.listToAttrs (map (mon: {
+ name = mon.name;
+ value = {
+ dpms = "on";
+ scale = toString mon.scale;
+ render_bit_depth = toString mon.bitdepth;
+ };
+ })
+ config.monitors))
+ // {
+ # wallpaper
+ "*" = {
+ bg = "${config.theme.wallpaper} fill";
+ };
+ };
+
+ # inputs
+ input = {
+ "*" = {
+ xkb_layout = "us";
+ xkb_options = "compose:ralt";
+ xkb_numlock = "enable";
+ };
+
+ "type:touchpad" = {
+ tap = "enabled";
+ natural_scroll = "enabled";
+ middle_emulation = "enabled";
+ };
+ };
+
+ startup =
+ # autostart apps
+ builtins.map (command: {
+ inherit command;
+ always = false;
+ })
+ config.autoRun;
+
+ # colors
+ colors = let
+ base = "#${config.theme.colors.base}";
+ surface = "#${config.theme.colors.surface}";
+ primary = "#${config.theme.colors.primary}";
+ text = "#${config.theme.colors.text}";
+ white = "#${config.theme.colors.bright.white}";
+ error = "#${config.theme.colors.error}";
+ in rec {
+ background = base;
+
+ focused = {
+ border = primary;
+ background = base;
+ text = text;
+ indicator = white;
+ childBorder = primary;
+ };
+
+ focusedInactive = {
+ border = surface;
+ background = base;
+ text = text;
+ indicator = surface;
+ childBorder = surface;
+ };
+
+ unfocused = focusedInactive;
+
+ urgent = {
+ border = error;
+ background = error;
+ text = text;
+ indicator = error;
+ childBorder = error;
+ };
+
+ placeholder = unfocused;
+ };
+
+ window = {
+ titlebar = false;
+ border = config.theme.borderWidth;
+ };
+
+ floating = {
+ titlebar = false;
+ border = config.theme.borderWidth;
+ modifier = "Mod4 normal";
+ };
+
+ gaps = {
+ inner = config.theme.innerGap;
+ outer = config.theme.outerGap;
+ };
+
+ modes = {};
+ bars = [];
+ };
+
+ extraConfig = ''
+ # gestures
+ bindgesture swipe:right workspace prev
+ bindgesture swipe:left workspace next
+
+ # swayfx
+ corner_radius ${toString config.theme.outerRadius}
+ smart_corner_radius ${toString config.theme.outerRadius}
+ blur ${
+ if config.theme.blur
+ then "enabled"
+ else "disabled"
+ }
+ blur_radius 10
+ blur_passes 3
+ '';
+ };
+ };
+}
diff --git a/modules/desktops/sway/default.nix b/modules/desktops/sway/default.nix
new file mode 100644
index 0000000..df7f756
--- /dev/null
+++ b/modules/desktops/sway/default.nix
@@ -0,0 +1,41 @@
+{
+ lib,
+ config,
+ pkgs,
+ ...
+}: let
+ inherit (lib) mkIf mkDefault;
+ cfg = config.desktops;
+in {
+ imports = [
+ ./binds.nix
+ ./config.nix
+ ./idle.nix
+ ];
+
+ config = mkIf cfg.sway {
+ desktops.wayland = true;
+
+ xdg.portal = {
+ config = {
+ sway.common = ["gtk" "wlr"];
+ };
+ extraPortals = with pkgs; [
+ xdg-desktop-portal-wlr
+ ];
+ };
+
+ home-manager.users.${config.user} = {
+ wayland.windowManager.sway = {
+ enable = true;
+ package = pkgs.swayfx;
+
+ # FIXME: this is bad, but swayfx cannot build if set :(
+ checkConfig = false;
+
+ xwayland = true;
+ systemd.enable = true;
+ };
+ };
+ };
+}
diff --git a/modules/desktops/sway/idle.nix b/modules/desktops/sway/idle.nix
new file mode 100644
index 0000000..b3e3e06
--- /dev/null
+++ b/modules/desktops/sway/idle.nix
@@ -0,0 +1,27 @@
+{config, ...}: {
+ home-manager.users.${config.user} = {
+ services.swayidle = {
+ enable = config.desktops.sway;
+ systemdTarget = "sway-session.target";
+
+ timeouts = [
+ {
+ timeout = 300;
+ command = "${config.default.lockScreen}";
+ }
+ {
+ timeout = 300;
+ command = "swaymsg \"output * power off\"";
+ resumeCommand = "swaymsg \"output * power on\"";
+ }
+ ];
+
+ events = [
+ {
+ event = "before-sleep";
+ command = "${config.default.lockScreen}";
+ }
+ ];
+ };
+ };
+}