-
Notifications
You must be signed in to change notification settings - Fork 0
/
sway.nix
181 lines (163 loc) · 7.15 KB
/
sway.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{ config, pkgs, lib, ... }:
let
# bash script to let dbus know about important env variables and
# propagate them to relevent services run at the end of sway config
# see
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
# note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts
# some user services to make sure they have the correct environment variables
dbus-sway-environment = pkgs.writeTextFile {
name = "dbus-sway-environment";
destination = "/bin/dbus-sway-environment";
executable = true;
text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
systemctl --user stop pipewire xdg-desktop-portal xdg-desktop-portal-wlr
systemctl --user start pipewire xdg-desktop-portal xdg-desktop-portal-wlr
'';
};
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
# the suggested way to set gtk settings is with gsettings
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
gsettings set $gnome_schema gtk-theme 'Dracula'
'';
};
in
{
wayland.windowManager.sway = {
enable = true;
config = rec {
bars = [{
statusCommand = "${pkgs.i3status}/bin/i3status";
}];
modifier = "Mod4";
terminal = "alacritty";
menu = "bemenu-run";
output.eDP-1.scale = "1.5";
keybindings = let cfg = config.wayland.windowManager.sway; in {
"${cfg.config.modifier}+Return" = "exec ${cfg.config.terminal}";
"${cfg.config.modifier}+Shift+q" = "kill";
"${cfg.config.modifier}+d" = "exec ${cfg.config.menu}";
"${cfg.config.modifier}+${cfg.config.left}" = "focus left";
"${cfg.config.modifier}+${cfg.config.down}" = "focus down";
"${cfg.config.modifier}+${cfg.config.up}" = "focus up";
"${cfg.config.modifier}+${cfg.config.right}" = "focus right";
"${cfg.config.modifier}+Left" = "focus left";
"${cfg.config.modifier}+Down" = "focus down";
"${cfg.config.modifier}+Up" = "focus up";
"${cfg.config.modifier}+Right" = "focus right";
"${cfg.config.modifier}+Shift+${cfg.config.left}" = "move left";
"${cfg.config.modifier}+Shift+${cfg.config.down}" = "move down";
"${cfg.config.modifier}+Shift+${cfg.config.up}" = "move up";
"${cfg.config.modifier}+Shift+${cfg.config.right}" = "move right";
"${cfg.config.modifier}+Shift+Left" = "move left";
"${cfg.config.modifier}+Shift+Down" = "move down";
"${cfg.config.modifier}+Shift+Up" = "move up";
"${cfg.config.modifier}+Shift+Right" = "move right";
"${cfg.config.modifier}+b" = "splith";
"${cfg.config.modifier}+v" = "splitv";
"${cfg.config.modifier}+f" = "fullscreen toggle";
"${cfg.config.modifier}+a" = "focus parent";
"${cfg.config.modifier}+t" = "floating toggle";
"${cfg.config.modifier}+s" = "layout stacking";
"${cfg.config.modifier}+w" = "layout tabbed";
"${cfg.config.modifier}+e" = "layout toggle split";
"${cfg.config.modifier}+1" = "workspace number 1";
"${cfg.config.modifier}+2" = "workspace number 2";
"${cfg.config.modifier}+3" = "workspace number 3";
"${cfg.config.modifier}+4" = "workspace number 4";
"${cfg.config.modifier}+5" = "workspace number 5";
"${cfg.config.modifier}+6" = "workspace number 6";
"${cfg.config.modifier}+7" = "workspace number 7";
"${cfg.config.modifier}+8" = "workspace number 8";
"${cfg.config.modifier}+9" = "workspace number 9";
"${cfg.config.modifier}+0" = "workspace number 10";
"${cfg.config.modifier}+Shift+1" =
"move container to workspace number 1";
"${cfg.config.modifier}+Shift+2" =
"move container to workspace number 2";
"${cfg.config.modifier}+Shift+3" =
"move container to workspace number 3";
"${cfg.config.modifier}+Shift+4" =
"move container to workspace number 4";
"${cfg.config.modifier}+Shift+5" =
"move container to workspace number 5";
"${cfg.config.modifier}+Shift+6" =
"move container to workspace number 6";
"${cfg.config.modifier}+Shift+7" =
"move container to workspace number 7";
"${cfg.config.modifier}+Shift+8" =
"move container to workspace number 8";
"${cfg.config.modifier}+Shift+9" =
"move container to workspace number 9";
"${cfg.config.modifier}+Shift+0" =
"move container to workspace number 10";
"${cfg.config.modifier}+Shift+minus" = "move scratchpad";
"${cfg.config.modifier}+minus" = "scratchpad show";
"${cfg.config.modifier}+Shift+c" = "reload";
"${cfg.config.modifier}+Shift+e" =
"exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'";
"${cfg.config.modifier}+r" = "mode resize";
};
startup = [
#{ command = "firefox"; }
];
};
};
home.packages = with pkgs; [
grim
slurp
sway
swaybg
swaylock
swayidle
dbus-sway-environment
wayland
configure-gtk
wl-clipboard
xdg-utils # for openning default programms when clicking links
glib # gsettings
bemenu # wayland clone of dmenu
mako # notification daemon
pamixer
playerctl
#FIXME: fcitx5 seems not working with alacritty, relegated to using XWayland
#(writeShellScriptBin "alacritty" ''WINIT_UNIX_BACKEND=x11 ${pkgs.alacritty}/bin/alacritty "$@"'')
];
# warning: xdg-desktop-portal 1.17 reworked how portal implementations are loaded
# https://github.com/flatpak/xdg-desktop-portal/blob/1.18.1/doc/portals.conf.rst.in
xdg.portal = {
enable = true;
extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr ];
config.common.default = "*";
};
# screenshots
# bindsym $mod+c exec grim -g "$(slurp)" /tmp/$(date +'%H:%M:%S.png')
# systemd.user.services.swayidle = {
# description = "Idle Manager for Wayland";
# documentation = [ "man:swayidle(1)" ];
# wantedBy = [ "sway-session.target" ];
# partOf = [ "graphical-session.target" ];
# path = [ pkgs.bash ];
# serviceConfig = {
# ExecStart = ''
# ${pkgs.swayidle}/bin/swayidle -w -d \
# timeout 300 '${pkgs.sway}/bin/swaymsg "output * dpms off"' \
# resume '${pkgs.sway}/bin/swaymsg "output * dpms on"'
# '';
# };
# };
}