This repository has no description
11 kB
346 lines
1{ config, lib, pkgs, ... }: let
2
3 term = "/run/current-system/sw/bin/alacritty";
4
5in {
6 imports = [
7 ../alacritty.nix
8 ../mpv.nix
9 ../power-action.nix
10 ../urxvt.nix
11 ../xdg-open.nix
12 ../yubikey.nix
13 ../tmux.nix
14 ../themes.nix
15 ../fonts.nix
16 # ./pipewire.nix
17 # ./tty-share.nix
18 {
19 users.users.mainUser.packages = [
20 pkgs.sshuttle
21 ];
22 security.sudo.extraConfig = ''
23 lass ALL= (root) NOPASSWD:SETENV: ${pkgs.sshuttle}/bin/.sshuttle-wrapped
24 '';
25 }
26 ];
27 users.users.mainUser.extraGroups = [ "audio" "pipewire" "video" "input" ];
28
29 services.clipmenu.enable = true;
30
31 services.udev.extraRules = ''
32 SUBSYSTEM=="backlight", ACTION=="add", \
33 RUN+="${pkgs.coreutils}/bin/chgrp video /sys/class/backlight/%k/brightness", \
34 RUN+="${pkgs.coreutils}/bin/chmod g+w /sys/class/backlight/%k/brightness"
35 '';
36
37 nixpkgs.config.packageOverrides = super: {
38 dmenu = pkgs.writeDashBin "dmenu" ''
39 unset TERM
40 ${pkgs.fzfmenu}/bin/fzfmenu "$@"
41 '';
42 };
43
44 environment.systemPackages = [
45 (pkgs.writers.writeDashBin "dmenu-wl" ''
46 unset TERM
47 ${pkgs.fzfmenu}/bin/fzfmenu "$@"
48 '')
49 pkgs.ydotool
50 pkgs.wl-clipboard
51 pkgs.fzfmenu
52 pkgs.glib
53 pkgs.dracula-theme
54 pkgs.gnome3.adwaita-icon-theme
55 ];
56
57 services.dbus.enable = true;
58 xdg.portal = {
59 enable = true;
60 wlr.enable = true;
61 # gtk portal needed to make gtk apps happy
62 extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
63 };
64 programs.sway = {
65 enable = true;
66 wrapperFeatures.gtk = true;
67 };
68
69 environment.etc."sway/config".text = ''
70 # Default config for sway
71 #
72 # Copy this to ~/.config/sway/config and edit it to your liking.
73 #
74 # Read `man 5 sway` for a complete reference.
75
76 ### Variables
77 #
78 # Logo key. Use Mod1 for Alt.
79 set $mod Mod4
80 # Home row direction keys, like vim
81 set $left h
82 set $down j
83 set $up k
84 set $right l
85 # Your preferred terminal emulator
86 set $term ${term}
87 # Your preferred application launcher
88 # Note: pass the final command to swaymsg so that the resulting window can be opened
89 # on the original workspace that the command was run on.
90 set $menu ${pkgs.dmenu}/bin/dmenu_path | fzfmenu | xargs swaymsg exec --
91
92 ### Output configuration
93 #
94 # Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
95 # output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
96 #
97 # Example configuration:
98 #
99 # output HDMI-A-1 resolution 1920x1080 position 1920,0
100 #
101 # You can get the names of your outputs by running: swaymsg -t get_outputs
102
103 ### Idle configuration
104 #
105 # Example configuration:
106 #
107 # exec swayidle -w \
108 # timeout 300 'swaylock -f -c 000000' \
109 # timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
110 # before-sleep 'swaylock -f -c 000000'
111 #
112 # This will lock your screen after 300 seconds of inactivity, then turn off
113 # your displays after another 300 seconds, and turn your screens back on when
114 # resumed. It will also lock your screen before your computer goes to sleep.
115
116 ### Input configuration
117 #
118 # Example configuration:
119 #
120 # input "2:14:SynPS/2_Synaptics_TouchPad" {
121 # dwt enabled
122 # tap enabled
123 # natural_scroll enabled
124 # middle_emulation enabled
125 # }
126 #
127 # You can get the names of your inputs by running: swaymsg -t get_inputs
128 # Read `man 5 sway-input` for more information about this section.
129
130 ### Key bindings
131 #
132 # Basics:
133 #
134 # Start a terminal
135 bindsym $mod+Shift+Return exec $term
136
137 # Kill focused window
138 bindsym $mod+Shift+c kill
139
140 # Start your launcher
141 bindsym $mod+d exec $menu
142
143 # Drag floating windows by holding down $mod and left mouse button.
144 # Resize them with right mouse button + $mod.
145 # Despite the name, also works for non-floating windows.
146 # Change normal to inverse to use left mouse button for resizing and right
147 # mouse button for dragging.
148 floating_modifier $mod normal
149
150 # Reload the configuration file
151 bindsym $mod+Shift+r reload
152
153 # Exit sway (logs you out of your Wayland session)
154 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'
155 #
156 # Moving around:
157 #
158 # Move your focus around
159 bindsym $mod+Left focus left
160 bindsym $mod+Down focus down
161 bindsym $mod+Up focus up
162 bindsym $mod+Right focus right
163
164 # Move the focused window with the same, but add Shift
165 bindsym $mod+Shift+Left move left
166 bindsym $mod+Shift+Down move down
167 bindsym $mod+Shift+Up move up
168 bindsym $mod+Shift+Right move right
169 # Layout stuff:
170 #
171 # You can "split" the current object of your focus with
172 # $mod+b or $mod+v, for horizontal and vertical splits
173 # respectively.
174 bindsym $mod+b splith
175 bindsym $mod+v splitv
176
177 # Switch the current container between different layout styles
178 bindsym $mod+s layout stacking
179 bindsym $mod+w layout tabbed
180 bindsym $mod+e layout toggle split
181
182 # Make the current focus fullscreen
183 bindsym $mod+f fullscreen
184
185 # Toggle the current focus between tiling and floating mode
186 bindsym $mod+Shift+space floating toggle
187
188 # Swap focus between the tiling area and the floating area
189 bindsym $mod+space focus mode_toggle
190
191 # Move focus to the parent container
192 bindsym $mod+Shift+a focus parent
193 #
194 # Scratchpad:
195 #
196 # Sway has a "scratchpad", which is a bag of holding for windows.
197 # You can send windows there and get them back later.
198
199 # Move the currently focused window to the scratchpad
200 bindsym $mod+Shift+minus move scratchpad
201
202 # Show the next scratchpad window or hide the focused scratchpad window.
203 # If there are multiple scratchpad windows, this command cycles through them.
204 bindsym $mod+minus scratchpad show
205 #
206 # Resizing containers:
207 #
208 mode "resize" {
209 # left will shrink the containers width
210 # right will grow the containers width
211 # up will shrink the containers height
212 # down will grow the containers height
213 bindsym $left resize shrink width 10px
214 bindsym $down resize grow height 10px
215 bindsym $up resize shrink height 10px
216 bindsym $right resize grow width 10px
217
218 # Ditto, with arrow keys
219 bindsym Left resize shrink width 10px
220 bindsym Down resize grow height 10px
221 bindsym Up resize shrink height 10px
222 bindsym Right resize grow width 10px
223
224 # Return to default mode
225 bindsym Return mode "default"
226 bindsym Escape mode "default"
227 }
228 bindsym $mod+r mode "resize"
229
230 #
231 # Status Bar:
232 #
233 # Read `man 5 sway-bar` for more information about this section.
234 bar {
235 position top
236
237 # When the status_command prints a new line to stdout, swaybar updates.
238 # The default just shows the current date and time.
239 status_command while date +'%Y-%m-%d %H:%M:%S'; do sleep 1; done
240
241 colors {
242 statusline #ffffff
243 background #323232
244 inactive_workspace #32323200 #32323200 #5c5c5c
245 }
246 }
247
248 default_border pixel 1
249 default_floating_border none
250 smart_borders on
251
252 bindsym $mod+q exec ${pkgs.writers.writeDash "goto_workspace" ''
253 set -efux
254 unset TERM # we want fzfmenu to start a new terminal
255 CURRENT_OUTPUT=$(swaymsg -r -t get_outputs | jq '.[] | select(.focused == true).name')
256 FZFMENU_FZF_DEFAULT_OPTS="--select-1"
257 WS=$(swaymsg -r -t get_workspaces |
258 jq -r '.[].name' |
259 fzfmenu -p 'Workspace name: '
260 )
261 if [ -n "$WS" ]; then
262 swaymsg workspace "$WS"
263 swaymsg move workspace to output "$CURRENT_OUTPUT"
264 fi
265 ''}
266
267 bindsym $mod+Shift+q exec ${pkgs.writers.writeDash "moveto_workspace" ''
268 set -efux
269 unset TERM # we want fzfmenu to start a new terminal
270 FZFMENU_FZF_DEFAULT_OPTS="--select-1"
271 WS=$(swaymsg -r -t get_workspaces |
272 jq -r '.[].name' |
273 fzfmenu -p 'Workspace name: '
274 )
275 if [ -n "$WS" ]; then
276 swaymsg move container to workspace "$WS"
277 fi
278 ''}
279
280 bindsym $mod+x exec ${./starter} floating enable -- ${pkgs.alacritty}/bin/alacritty --config-file /var/theme/config/alacritty.yaml
281 bindsym $mod+y exec /run/current-system/sw/bin/switch-theme toggle
282
283 for_window [title="fzfmenu"] floating enable
284 bindsym $mod+Tab focus next
285 bindsym $mod+Escape workspace back_and_forth
286
287 bindsym $mod+p exec ${pkgs.writers.writeDash "passmenu" ''
288 set -efux
289 unset TERM # we want fzfmenu to start a new terminal
290 (cd $HOME/.password-store; find -type f -name '*.gpg') |
291 sed -e 's/\.gpg$//' |
292 fzfmenu -p 'Password: ' |
293 xargs -I{} pass show {} |
294 tr -d '\n' |
295 ${pkgs.wtype}/bin/wtype -s 1 -
296 ''}
297 bindsym $mod+Shift+p exec ${pkgs.writers.writeDash "otpmenu" ''
298 unset TERM
299 ${pkgs.otpmenu}/bin/otpmenu
300 ''}
301
302 # screenlock
303 bindsym $mod+F11 exec ${pkgs.swaylock}/bin/swaylock -f -c 000000
304
305 # media buttons
306 bindsym XF86AudioMute exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-mute @DEFAULT_SINK@ toggle
307 bindsym XF86AudioRaiseVolume exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ +4%
308 bindsym XF86AudioLowerVolume exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ -4%
309 bindsym XF86MonBrightnessDown exec ${pkgs.acpilight}/bin/xbacklight -time 0 -dec 1
310 bindsym XF86MonBrightnessUp exec ${pkgs.acpilight}/bin/xbacklight -time 0 -inc 1
311
312 # background programs
313 exec ydotoold
314 exec_always pkill kanshi; exec ${pkgs.kanshi}/bin/kanshi
315
316 # theme and env specific stuff
317 exec_always ${pkgs.writers.writeDash "dbus-sway-environment" ''
318 set -efux
319 dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
320 systemctl --user stop xdg-desktop-portal xdg-desktop-portal-wlr
321 systemctl --user start xdg-desktop-portal xdg-desktop-portal-wlr
322 ''}
323
324 exec_always ${let
325 schema = pkgs.gsettings-desktop-schemas;
326 datadir = "${schema}/share/gsettings-schemas/${schema.name}";
327 in pkgs.writers.writeDash "gsettings" ''
328 set -efux
329 export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}:$XDG_DATA_DIRS
330 gnome_schema=org.gnome.desktop.interface
331 gsettings set $gnome_schema gtk-theme 'Dracula'
332 ''}
333
334 # keyboard
335 input type:keyboard {
336 xkb_layout us
337 xkb_variant altgr-intl
338 xkb_options caps:hyper
339 }
340
341 # flameshot
342 for_window [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
343 exec ${pkgs.flameshot}/bin/flameshot
344 '';
345
346}