-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsway.nix
333 lines (317 loc) · 9.58 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
{
inputs,
system,
pkgs,
lib,
config,
bg,
...
}: let
update-lid =
pkgs.writeShellScript
"update-lid"
''
if grep -q open /proc/acpi/button/lid/LID/state; then
swaymsg output eDP-1 enable
else
swaymsg output eDP-1 disable
fi
'';
in {
nixpkgs.overlays = [
(_: prev: {
sway-new-workspace = inputs.sway-new-workspace.packages.${system}.default;
swayws = let
pkg = {
lib,
rustPlatform,
}:
rustPlatform.buildRustPackage {
pname = "swayws";
version = "1.2.0-mikidep";
src = inputs.swayws-src;
cargoHash = "sha256-MXP/MDd/PXDFEeNwZOTxg0Ac1Z5NbY/Li7+7rvN8rB8=";
# swayws does not have any tests
doCheck = false;
meta = with lib; {
description = "Sway workspace tool which allows easy moving of workspaces to and from outputs";
mainProgram = "swayws";
homepage = "https://gitlab.com/mikidep/swayws";
license = licenses.mit;
maintainers = [maintainers.atila];
};
};
in
pkgs.callPackage pkg {};
})
];
home.packages = with pkgs; [
swaybg
swaynotificationcenter
sway-contrib.grimshot
];
# nixpkgs.overlays = [
# (_: _: {
# xwayland = pkgs-stable.xwayland;
# })
# ];
programs.waybar = {
enable = true;
systemd.enable = true;
settings.mainBar = {
position = "bottom";
layer = "top";
modules-left = ["sway/workspaces" "sway/mode"];
modules-center = ["sway/window"];
modules-right = ["memory" "network" "disk" "wireplumber" "battery" "clock"];
"sway/window" = {
max-length = 50;
};
battery = {
format = "{capacity}% {icon} ";
format-icons = ["" "" "" "" ""];
};
clock = {
format = "{:%a, %d. %b %H:%M}";
};
network = {
format-wifi = "{essid} ({signalStrength}%) ";
format-ethernet = "{ipaddr}/{cidr} ";
};
disk = {
path = "/";
format = "DU {percentage_used}%";
};
wireplumber = {
on-click = lib.getExe pkgs.qpwgraph;
format = "{node_name} {volume}% {icon}";
format-muted = "";
};
memory = {
format = "RAM {percentage}%";
interval = 5;
};
};
};
programs.swaylock = {
enable = true;
settings = {
color = "000000";
indicator-idle-visible = true;
};
};
services.swayidle = let
swaylock = lib.getExe pkgs.swaylock;
in {
enable = false;
events = [
{
event = "before-sleep";
command = "${swaylock}";
}
];
};
programs.swayr = {
enable = true;
systemd.enable = true;
};
wayland.windowManager.sway = let
rofi = "${pkgs.rofi-wayland}/bin/rofi";
rofi-pm = lib.getExe pkgs.rofi-power-menu;
rofi-menu = ''${rofi} -show combi -combi-modes "pm:${rofi-pm},window,drun" -show-icons -theme solarized'';
rofi-run = ''${rofi} -show run -theme solarized'';
terminal = lib.getExe pkgs.kitty;
# # 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.writeShellScript
# "configure-gtk"
# (
# 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 {
enable = true;
package = let
cfg = config.wayland.windowManager.sway;
in
(pkgs.sway.overrideAttrs {
version = "1.10";
})
.override {
extraSessionCommands = cfg.extraSessionCommands;
extraOptions = cfg.extraOptions;
withBaseWrapper = cfg.wrapperFeatures.base;
withGtkWrapper = cfg.wrapperFeatures.gtk;
};
systemd.enable = true;
wrapperFeatures = {
base = true;
gtk = true;
};
config = {
input."*" = {
xkb_layout = "us(altgr-intl)";
xkb_numlock = "enabled";
xkb_options = "caps:escape";
tap = "enabled";
tap_button_map = "lrm";
};
input."1:1:AT_Translated_Set_2_keyboard" = {
xkb_layout = "it";
};
keybindings =
(
let
sway-workspace = let
repo = inputs.sway-workspace;
pkg = pkgs.rustPlatform.buildRustPackage {
name = "sway-workspace";
src = repo;
cargoHash = "sha256-8gT/2RUDIOnmTznjlzupIapHjz2pNQjj3DZ0dg8f+VM=";
};
in
lib.getExe' pkg "sway-workspace";
swayws = lib.getExe pkgs.swayws;
movements = {
left,
right,
up,
down,
}: {
"Mod4+${left}" = "focus prev";
"Mod4+${right}" = "focus next";
"Mod4+${up}" = "focus parent";
"Mod4+${down}" = "focus child";
"Mod4+Shift+${left}" = "move left";
"Mod4+Shift+${right}" = "move right";
"Mod4+Shift+${up}" = "move up";
"Mod4+Shift+${down}" = "move down";
"Ctrl+Alt+${left}" = "workspace prev_on_output";
"Ctrl+Alt+${right}" = "workspace next_on_output";
"Ctrl+Alt+${up}" = "exec ${sway-workspace} prev-output";
"Ctrl+Alt+${down}" = "exec ${sway-workspace} next-output";
"Ctrl+Alt+Shift+${left}" = "move container to workspace prev_on_output, workspace prev_on_output;";
"Ctrl+Alt+Shift+${right}" = "move container to workspace next_on_output, workspace next_on_output;";
"Ctrl+Alt+Shift+${up}" = "exec ${sway-workspace} --move prev-output";
"Ctrl+Alt+Shift+${down}" = "exec ${sway-workspace} --move next-output";
"Ctrl+Mod4+Shift+${left}" = "exec ${swayws} swap current prev";
"Ctrl+Mod4+Shift+${right}" = "exec ${swayws} swap current next";
};
in
(movements {
left = "H";
right = "L";
down = "J";
up = "K";
})
// (movements {
left = "Left";
right = "Right";
down = "Down";
up = "Up";
})
)
// (
let
sway-nw = lib.getExe' pkgs.sway-new-workspace "sway-new-workspace";
unmute = "wpctl set-mute @DEFAULT_AUDIO_SINK@ 0";
grimshot = lib.getExe pkgs.sway-contrib.grimshot;
brightnessctl = lib.getExe pkgs.brightnessctl;
in {
"Ctrl+Alt+N" = "exec ${sway-nw} open";
"Ctrl+Alt+Shift+N" = "exec ${sway-nw} move";
"Alt+F2" = "exec ${rofi-run}";
"Mod4+space" = "exec ${rofi-menu}";
"Mod4+V" = "layout toggle all";
"Shift+Mod4+Q" = "kill";
"Mod4+Return" = "exec ${terminal}";
"Mod4+R" = "mode resize";
"Print" = "exec ${grimshot} copy anything";
"Shift+Print" = "exec ${grimshot} copy output";
"XF86AudioRaiseVolume" = "exec ${unmute}; exec wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%+";
"XF86AudioLowerVolume" = "exec ${unmute}; exec wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%-";
"XF86MonBrightnessUp" = "exec ${brightnessctl} s +10%";
"XF86MonBrightnessDown" = "exec ${brightnessctl} s 10%-";
"XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
}
);
modes.resize = {
"Escape" = "mode default";
"L" = "resize grow width 10 px";
"H" = "resize shrink width 10 px";
};
output = {
"*" = {
bg = "${bg} center #000000";
};
"Dell Inc. DELL P2719HC H5F9QS2" = {
scale = "1";
};
"Dell Inc. DELL S2721D DTNDP43" = {
scale = "1.25";
};
"LG Electronics LG HDR 4K 0x0007B5E8" = {
scale = "2";
};
};
window.titlebar = false;
window.commands = [
{
command = "layout tabbed";
criteria.app_id = "org.pwmt.zathura";
}
];
assigns = {
"20: IM" = [
{title = "whatsapp";}
{app_id = "telegram";}
];
};
menu = rofi-menu;
modifier = "Mod4";
bars = [];
gaps = {
inner = 3;
smartGaps = true;
smartBorders = "on";
};
focus = {
followMouse = false;
newWindow = "urgent";
};
startup = [
{
command = update-lid.outPath;
always = true;
}
{
command = let
python-i3ipc = lib.getExe (pkgs.python312.withPackages (p: [p.i3ipc]));
in "${python-i3ipc} ${inputs.i3-switch-if-workspace-empty}/i3-switch-if-workspace-empty";
always = true;
}
];
};
extraConfig = ''
bindswitch lid:on exec ${update-lid}
bindswitch lid:off exec ${update-lid}
workspace 1
exec firefox
workspace 2
exec ${terminal}
exec telegram-desktop
exec whatsapp
'';
};
}