forked from
lass.pds.lassul.us/superconfig
This repository has no description
13 kB
416 lines
1{ pkgs, lib, ... }:
2let
3
4 term = "/run/current-system/sw/bin/alacritty";
5
6 waybarConfig = pkgs.writeText "waybar-config.json" (
7 builtins.toJSON {
8 height = 30;
9 spacing = 4;
10 modules-left = [
11 "sway/workspaces"
12 "sway/mode"
13 "sway/scratchpad"
14 ];
15 modules-center = [ "sway/window" ];
16 modules-right = [
17 "idle_inhibitor"
18 "pulseaudio"
19 "network"
20 "cpu"
21 "memory"
22 "temperature"
23 "backlight"
24 "battery"
25 "clock"
26 "tray"
27 ];
28
29 "sway/mode".format = "<span style=\"italic\">{}</span>";
30
31 "sway/scratchpad" = {
32 format = "{icon} {count}";
33 show-empty = false;
34 format-icons = [
35 ""
36 ""
37 ];
38 tooltip = true;
39 tooltip-format = "{app}: {title}";
40 };
41
42 idle_inhibitor = {
43 format = "{icon}";
44 format-icons = {
45 activated = "";
46 deactivated = "";
47 };
48 };
49
50 tray.spacing = 10;
51
52 clock = {
53 tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
54 format-alt = "{:%Y-%m-%d}";
55 };
56
57 cpu = {
58 format = "{usage}% ";
59 tooltip = false;
60 };
61
62 memory.format = "{}% ";
63
64 temperature = {
65 critical-threshold = 80;
66 format = "{temperatureC}°C {icon}";
67 format-icons = [
68 ""
69 ""
70 ""
71 ];
72 };
73
74 backlight = {
75 format = "{percent}% {icon}";
76 format-icons = [
77 ""
78 ""
79 ""
80 ];
81 };
82
83 battery = {
84 states = {
85 warning = 30;
86 critical = 15;
87 };
88 format = "{capacity}% {icon}";
89 format-full = "{capacity}% {icon}";
90 format-charging = "{capacity}% ";
91 format-plugged = "{capacity}% ";
92 format-alt = "{time} {icon}";
93 format-icons = [
94 ""
95 ""
96 ""
97 ""
98 ""
99 ""
100 ""
101 ""
102 ""
103 ""
104 ""
105 ];
106 };
107
108 network = {
109 format-wifi = "{essid} ({signalStrength}%) ";
110 format-ethernet = "{ipaddr}/{cidr} ";
111 tooltip-format = "{ifname} via {gwaddr} ";
112 format-linked = "{ifname} (No IP) ";
113 format-disconnected = "Disconnected ";
114 format-alt = "{ifname}: {ipaddr}/{cidr}";
115 };
116
117 pulseaudio = {
118 format = "{volume}% {icon} {format_source}";
119 format-bluetooth = "{volume}% {icon} {format_source}";
120 format-bluetooth-muted = " {icon} {format_source}";
121 format-muted = " {format_source}";
122 format-source = "{volume}% ";
123 format-source-muted = "";
124 format-icons = {
125 headphone = "";
126 hands-free = "";
127 headset = "";
128 phone = "";
129 portable = "";
130 car = "";
131 default = [
132 ""
133 ""
134 ""
135 ];
136 };
137 on-click = "pavucontrol";
138 };
139 }
140 );
141
142 waybarStyle = pkgs.writeText "waybar-style.css" ''
143 @import "${pkgs.waybar}/etc/xdg/waybar/style.css";
144 * {
145 font-family: "Iosevka Nerd Font", monospace;
146 }
147 '';
148
149in
150{
151 imports = [
152 ../lib/wayland.nix
153 ];
154 programs.sway = {
155 enable = true;
156 wrapperFeatures.gtk = true;
157 extraSessionCommands = ''
158 export SWAYSOCK=/run/user/$(id -u)/sway-ipc.sock
159 '';
160 };
161
162 systemd.user.services.waybar = {
163 description = "Highly customizable Wayland bar for Sway";
164 documentation = [ "man:waybar(5)" ];
165 partOf = [ "sway-session.target" ];
166 wantedBy = [ "sway-session.target" ];
167 serviceConfig = {
168 Type = "simple";
169 ExecStart = "${pkgs.waybar}/bin/waybar -c ${waybarConfig} -s ${waybarStyle}";
170 Restart = "on-failure";
171 RestartSec = 1;
172 };
173 };
174
175 environment.etc."sway/config".text = ''
176 # Default config for sway
177 #
178 # Copy this to ~/.config/sway/config and edit it to your liking.
179 #
180 # Read `man 5 sway` for a complete reference.
181
182 ### Variables
183 #
184 # Logo key. Use Mod1 for Alt.
185 set $mod Mod4
186 # Home row direction keys, like vim
187 set $left h
188 set $down j
189 set $up k
190 set $right l
191 # Your preferred terminal emulator
192 set $term ${term}
193 # Your preferred application launcher
194 # Note: pass the final command to swaymsg so that the resulting window can be opened
195 # on the original workspace that the command was run on.
196 set $menu ${pkgs.dmenu}/bin/dmenu_path | menu | xargs swaymsg exec --
197
198 ### Output configuration
199 #
200 # Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
201 # output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
202 #
203 # Example configuration:
204 #
205 # output HDMI-A-1 resolution 1920x1080 position 1920,0
206 #
207 # You can get the names of your outputs by running: swaymsg -t get_outputs
208
209 ### Idle configuration
210 #
211 # Example configuration:
212 #
213 # exec swayidle -w \
214 # timeout 300 'swaylock -f -c 000000' \
215 # timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
216 # before-sleep 'swaylock -f -c 000000'
217 #
218 # This will lock your screen after 300 seconds of inactivity, then turn off
219 # your displays after another 300 seconds, and turn your screens back on when
220 # resumed. It will also lock your screen before your computer goes to sleep.
221
222 ### Input configuration
223 #
224 # Example configuration:
225 #
226 input "2321:21128:HTIX5288:00_0911:5288_Touchpad" {
227 tap enabled
228 }
229 #
230 # You can get the names of your inputs by running: swaymsg -t get_inputs
231 # Read `man 5 sway-input` for more information about this section.
232
233 ### Key bindings
234 #
235 # Basics:
236 #
237 # Start a terminal
238 bindsym $mod+Shift+Return exec $term
239
240 # Kill focused window
241 bindsym $mod+Shift+c kill
242
243 # Start your launcher
244 bindsym $mod+d exec $menu
245
246 # Drag floating windows by holding down $mod and left mouse button.
247 # Resize them with right mouse button + $mod.
248 # Despite the name, also works for non-floating windows.
249 # Change normal to inverse to use left mouse button for resizing and right
250 # mouse button for dragging.
251 floating_modifier $mod normal
252
253 # Reload the configuration file
254 bindsym $mod+Shift+r reload
255
256 # Exit sway (logs you out of your Wayland session)
257 bindsym $mod+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'
258 #
259 # Moving around:
260 #
261 # Move your focus around
262 bindsym $mod+Left focus left
263 bindsym $mod+Down focus down
264 bindsym $mod+Up focus up
265 bindsym $mod+Right focus right
266
267 # Move the focused window with the same, but add Shift
268 bindsym $mod+Shift+Left move left
269 bindsym $mod+Shift+Down move down
270 bindsym $mod+Shift+Up move up
271 bindsym $mod+Shift+Right move right
272 # Layout stuff:
273 #
274 # You can "split" the current object of your focus with
275 # $mod+b or $mod+v, for horizontal and vertical splits
276 # respectively.
277 bindsym $mod+b splith
278 bindsym $mod+v splitv
279
280 # Switch the current container between different layout styles
281 bindsym $mod+s layout stacking
282 bindsym $mod+w layout tabbed
283 bindsym $mod+e layout toggle split
284
285 # Make the current focus fullscreen
286 bindsym $mod+f fullscreen
287
288 # Toggle the current focus between tiling and floating mode
289 bindsym $mod+Shift+space floating toggle
290
291 # Swap focus between the tiling area and the floating area
292 bindsym $mod+space focus mode_toggle
293
294 # Move focus to the parent container
295 bindsym $mod+Shift+a focus parent
296 #
297 # Scratchpad:
298 #
299 # Sway has a "scratchpad", which is a bag of holding for windows.
300 # You can send windows there and get them back later.
301
302 # Move the currently focused window to the scratchpad
303 bindsym $mod+Shift+minus move scratchpad
304
305 # Show the next scratchpad window or hide the focused scratchpad window.
306 # If there are multiple scratchpad windows, this command cycles through them.
307 bindsym $mod+minus scratchpad show
308 #
309 # Resizing containers:
310 #
311 mode "resize" {
312 # left will shrink the containers width
313 # right will grow the containers width
314 # up will shrink the containers height
315 # down will grow the containers height
316 bindsym $left resize shrink width 10px
317 bindsym $down resize grow height 10px
318 bindsym $up resize shrink height 10px
319 bindsym $right resize grow width 10px
320
321 # Ditto, with arrow keys
322 bindsym Left resize shrink width 10px
323 bindsym Down resize grow height 10px
324 bindsym Up resize shrink height 10px
325 bindsym Right resize grow width 10px
326
327 # Return to default mode
328 bindsym Return mode "default"
329 bindsym Escape mode "default"
330 }
331 bindsym $mod+r mode "resize"
332
333 default_border pixel 1
334 default_floating_border none
335 smart_borders on
336
337 bindsym $mod+q exec ${pkgs.writers.writeDash "goto_workspace" ''
338 set -efux
339 CURRENT_OUTPUT=$(swaymsg -r -t get_outputs | jq '.[] | select(.focused == true).name')
340 WS=$(swaymsg -r -t get_workspaces |
341 jq -r '.[].name' |
342 menu -p 'Workspace name: '
343 )
344 if [ -n "$WS" ]; then
345 swaymsg workspace "$WS"
346 swaymsg move workspace to output "$CURRENT_OUTPUT"
347 fi
348 ''}
349
350 bindsym $mod+Shift+q exec ${pkgs.writers.writeDash "moveto_workspace" ''
351 set -efux
352 WS=$(swaymsg -r -t get_workspaces |
353 jq -r '.[].name' |
354 menu -p 'Workspace name: '
355 )
356 if [ -n "$WS" ]; then
357 swaymsg move container to workspace "$WS"
358 fi
359 ''}
360
361 bindsym $mod+y exec /run/current-system/sw/bin/switch-theme toggle
362
363 bindsym $mod+Tab focus next
364 bindsym $mod+Escape workspace back_and_forth
365
366 # screenlock
367 bindsym $mod+F11 exec ${lib.getExe' pkgs.systemd "systemctl"} --user start lock.target
368
369 # media buttons
370 bindsym XF86AudioMute exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-mute @DEFAULT_SINK@ toggle
371 bindsym XF86AudioRaiseVolume exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ +4%
372 bindsym XF86AudioLowerVolume exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ -4%
373
374 # brightness keys
375 bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%-
376 bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+
377
378 # background programs
379 exec ydotoold
380 exec_always pkill kanshi; exec ${pkgs.kanshi}/bin/kanshi
381 exec_always pkill swayidle; exec ${pkgs.swayidle}/bin/swayidle -w \
382 timeout 120 '${lib.getExe' pkgs.systemd "systemctl"} --user start lock.target' \
383 timeout 300 '${lib.getExe' pkgs.systemd "systemctl"} suspend' \
384 before-sleep '${lib.getExe' pkgs.systemd "systemctl"} --user start lock.target'
385 exec_always pkill sway-audio-idle-inhibit; exec ${pkgs.sway-audio-idle-inhibit}/bin/sway-audio-idle-inhibit
386
387 # theme and env specific stuff
388 exec_always ${pkgs.writers.writeDash "dbus-sway-environment" ''
389 set -efux
390 dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP=sway
391 systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
392 systemctl --user restart --no-block sway-session.target
393 systemctl --user stop xdg-desktop-portal xdg-desktop-portal-wlr
394 systemctl --user start xdg-desktop-portal xdg-desktop-portal-wlr
395 ''}
396
397 exec_always ${pkgs.writers.writeDash "gsettings" ''
398 set -efux
399 export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}:$XDG_DATA_DIRS
400 gnome_schema=org.gnome.desktop.interface
401 gsettings set $gnome_schema gtk-theme 'Dracula'
402 ''}
403
404 # keyboard
405 input type:keyboard {
406 xkb_layout us
407 xkb_variant altgr-intl
408 xkb_options caps:hyper
409 }
410
411 # flameshot
412 for_window [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
413 exec ${pkgs.flameshot}/bin/flameshot
414 '';
415
416}