i3.nix (15418B)
1 { config, nixosConfig, lib, pkgs, ... }: 2 3 with lib; 4 let 5 # FIXME(change this at some point) 6 powermenu = pkgs.writeScript "powermenu.sh" '' 7 #!/usr/bin/env bash 8 MENU="$(${pkgs.rofi}/bin/rofi -sep "|" -dmenu -i -p 'System' -location 3 -xoffset -10 -yoffset 32 -width 20 -hide-scrollbar -line-padding 4 -padding 20 -lines 5 <<< "Suspend|Hibernate|Reboot|Shutdown")" 9 case "$MENU" in 10 *Suspend) systemctl suspend;; 11 *Hibernate) systemctl hibernate;; 12 *Reboot) systemctl reboot ;; 13 *Shutdown) systemctl -i poweroff 14 esac 15 ''; 16 emacs-in-folder = pkgs.writeScript "emacs-in-folder" '' 17 #!/usr/bin/env bash 18 fd . -d 3 --type d ~/src | rofi -dmenu | xargs -I {} zsh -i -c "cd {}; emacs ." 19 ''; 20 lockCommand = "${pkgs.betterlockscreen}/bin/betterlockscreen -l dim"; 21 in 22 { 23 imports = [ 24 ./alacritty.nix 25 ./autorandr.nix 26 # ./dconf.nix 27 ./xsession.nix 28 ]; 29 home.sessionVariables = { WEBKIT_DISABLE_COMPOSITING_MODE = 1; }; 30 home.packages = with pkgs; [ 31 alacritty 32 kitty 33 arandr 34 # TODO switch to betterlockscreen 35 i3lock-color 36 libnotify 37 maim 38 slop 39 # Gnome3 relica 40 # gnome3.dconf-editor 41 # FIXME move this elsewhere 42 pop-gtk-theme 43 pop-icon-theme 44 pinentry-gnome 45 46 aspell 47 aspellDicts.en 48 aspellDicts.fr 49 hunspell 50 hunspellDicts.en_US-large 51 hunspellDicts.en_GB-ize 52 hunspellDicts.fr-any 53 wmctrl 54 xclip 55 xdg-user-dirs 56 xdg-utils 57 xsel 58 ]; 59 xdg.configFile."rofi/slate.rasi".text = '' 60 * { 61 background-color: #282C33; 62 border-color: #2e343f; 63 text-color: #8ca0aa; 64 spacing: 0; 65 width: 512px; 66 } 67 68 inputbar { 69 border: 0 0 1px 0; 70 children: [prompt,entry]; 71 } 72 73 prompt { 74 padding: 16px; 75 border: 0 1px 0 0; 76 } 77 78 textbox { 79 background-color: #2e343f; 80 border: 0 0 1px 0; 81 border-color: #282C33; 82 padding: 8px 16px; 83 } 84 85 entry { 86 padding: 16px; 87 } 88 89 listview { 90 cycle: false; 91 margin: 0 0 -1px 0; 92 scrollbar: false; 93 } 94 95 element { 96 border: 0 0 1px 0; 97 padding: 16px; 98 } 99 100 element selected { 101 background-color: #2e343f; 102 } 103 ''; 104 programs.kitty = { 105 enable = true; 106 settings = { 107 term = "xterm-256color"; 108 close_on_child_death = "yes"; 109 font_family = "Ubuntu Mono"; 110 }; 111 theme = "Tango Light"; 112 }; 113 programs.rofi = { 114 enable = true; 115 package = pkgs.rofi.override { plugins = [ pkgs.rofi-emoji pkgs.rofi-menugen pkgs.rofi-mpd ]; }; 116 font = "Ubuntu Mono 14"; 117 terminal = "${pkgs.kitty}/bin/kitty"; 118 theme = "slate"; 119 }; 120 services = { 121 blueman-applet.enable = true; 122 pasystray.enable = true; 123 dunst = { 124 enable = true; 125 settings = { 126 global = { 127 geometry = "500x5-10+10"; 128 follow = "keyboard"; 129 frame_color = "#cccccc"; 130 font = "Ubuntu Mono 11"; 131 indicate_hidden = "yes"; 132 separator_height = 1; 133 padding = 8; 134 horizontal_padding = 8; 135 frame_width = 2; 136 sort = "yes"; 137 markup = "full"; 138 format = "<b>%s</b>\n%b"; 139 ignore_newline = "no"; 140 stack_duplicates = true; 141 show_indicators = "yes"; 142 history_length = 40; 143 }; 144 shortcuts = { 145 close = "ctrl+space"; 146 close_all = "ctrl+shift+space"; 147 history = "ctrl+percent"; 148 context = "ctrl+shift+period"; 149 }; 150 urgency_low = { 151 background = "#000000"; 152 foreground = "#ffffff"; 153 timeout = 4; 154 }; 155 urgency_normal = { 156 background = "#000000"; 157 foreground = "#ffffff"; 158 timeout = 6; 159 }; 160 urgency_critical = { 161 background = "#000000"; 162 foreground = "#cf6a4c"; 163 timeout = 0; 164 }; 165 }; 166 }; 167 udiskie.enable = true; 168 network-manager-applet.enable = true; 169 /* 170 screern-locker = { 171 enable = true; 172 lockCmd = lockCommand; 173 inactiveInterval = 60; 174 xautolock = { 175 enable = true; 176 detectSleep = true; 177 }; 178 }; 179 */ 180 random-background = { 181 enable = true; 182 enableXinerama = true; 183 imageDirectory = "${config.home.homeDirectory}/desktop/pictures/walls"; 184 interval = "5h"; 185 }; 186 }; 187 xsession.windowManager.i3 = { 188 package = pkgs.i3-gaps; 189 enable = true; 190 config = { 191 fonts = { 192 names = [ "Ubuntu Mono" ]; 193 size = 10.0; 194 }; 195 focus = { 196 followMouse = false; 197 }; 198 window = { 199 titlebar = false; 200 border = 1; 201 hideEdgeBorders = "both"; 202 }; 203 keybindings = { 204 "Mod4+Return" = "exec kitty"; 205 "Mod4+Shift+Return" = "exec emacsclient -c"; 206 "Mod4+Control+Return" = "exec emacs"; 207 "Mod4+Control+Shift+Return" = "exec ${emacs-in-folder}"; 208 }; 209 gaps = { 210 inner = 2; 211 outer = 2; 212 }; 213 keycodebindings = { 214 "Mod4+Shift+24" = "kill"; 215 "Mod4+33" = "exec \"rofi -show drun -modi 'drun,run,window,ssh' -kb-row-select 'Tab' -kb-row-tab '' -location 2 -hide-scrollbar -separator-style solid -font 'Ubuntu Mono 14'"; 216 "Mod4+Shift+33" = "exec \"rofi -show combi -modi 'drun,run,window,ssh,combi' -kb-row-select 'Tab' -kb-row-tab '' -location 2 -hide-scrollbar -separator-style solid -font 'Ubuntu Mono 14'"; 217 "Mod4+Control+33" = "exec \"rofi -show emoji -modi emoji -location 2 -hide-scrollbar -separator-style solid -font 'Ubuntu Mono 14'|pbcopy"; 218 # "Mod4+space" = ""; 219 # focus window 220 "Mod4+44" = "focus left"; 221 "Mod4+45" = "focus down"; 222 "Mod4+46" = "focus up"; 223 "Mod4+47" = "focus right"; 224 "Mod4+38" = "focus parent"; 225 # move focused window 226 "Mod4+Shift+44" = "move left"; 227 "Mod4+Shift+45" = "move down"; 228 "Mod4+Shift+46" = "move up"; 229 "Mod4+Shift+47" = "move right"; 230 # resize 231 "Mod4+Control+44" = "resize shrink width 5px or 5ppt"; 232 "Mod4+Control+45" = "resize grow width 5px or 5ppt"; 233 "Mod4+Control+46" = "resize shrink height 5px or 5ppt"; 234 "Mod4+Control+47" = "resize grow height 5px or 5ppt"; 235 # gaps 236 "Mod4+Mod1+44" = "gaps inner current plus 5"; 237 "Mod4+Mod1+45" = "gaps inner current minus 5"; 238 "Mod4+Mod1+46" = "gaps outer current plus 5"; 239 "Mod4+Mod1+47" = "gaps outer current minus 5"; 240 # Fullscreen 241 "Mod4+41" = "fullscreen toggle"; 242 # Change container layout 243 "Mod4+39" = "layout stacking"; 244 "Mod4+25" = "layout tabbed"; 245 "Mod4+26" = "layout toggle split"; 246 # Split 247 "Mod4+Control+39" = "split h"; 248 # Manage floating 249 "Mod4+Shift+61" = "floating toggle"; 250 "Mod4+61" = "focus mode_toggle"; 251 # manage workspace 252 "Mod4+113" = "workspace prev_on_output"; 253 "Mod4+112" = "workspace prev_on_output"; 254 "Mod4+114" = "workspace next_on_output"; 255 "Mod4+117" = "workspace next_on_output"; 256 # manage output 257 "Mod4+Shift+113" = "focus output left"; 258 "Mod4+Shift+116" = "focus output down"; 259 "Mod4+Shift+111" = "focus output up"; 260 "Mod4+Shift+114" = "focus output right"; 261 # Custom keybinding 262 "Mod4+Shift+32" = "exec ${lockCommand}"; 263 # "Mod4+Shift+39" = "exec ~/.screenlayout/home-work.sh && systemctl --user start random-background.service"; 264 "Mod4+24" = "border toggle"; 265 # TODO transform this into mode with multiple "capture" target 266 "Mod4+32" = "exec capture"; 267 }; 268 modes = { }; 269 bars = [ 270 { 271 mode = "hide"; 272 position = "bottom"; 273 trayOutput = "primary"; 274 statusCommand = "${pkgs.i3status}/bin/i3status"; 275 fonts = { 276 names = [ "Fira Code" ]; 277 size = 12.0; 278 }; 279 } 280 ]; 281 }; 282 extraConfig = '' 283 set $mod Mod4 284 285 # Use Mouse+$mod to drag floating windows to their wanted position 286 floating_modifier $mod 287 288 set $WS0 0 289 set $WS1 1 290 set $WS2 2 291 set $WS3 3 292 set $WS4 4 293 set $WS5 5 294 set $WS6 6 295 set $WS7 7 296 set $WS8 8 297 set $WS9 9 298 299 # switch to workspace 300 bindcode $mod+10 workspace $WS1 301 bindcode $mod+11 workspace $WS2 302 bindcode $mod+12 workspace $WS3 303 bindcode $mod+13 workspace $WS4 304 bindcode $mod+14 workspace $WS5 305 bindcode $mod+15 workspace $WS6 306 bindcode $mod+16 workspace $WS7 307 bindcode $mod+17 workspace $WS8 308 bindcode $mod+18 workspace $WS9 309 bindcode $mod+19 workspace $WS0 310 311 # move focused container to workspace 312 bindcode $mod+Shift+10 move container to workspace $WS1 313 bindcode $mod+Shift+11 move container to workspace $WS2 314 bindcode $mod+Shift+12 move container to workspace $WS3 315 bindcode $mod+Shift+13 move container to workspace $WS4 316 bindcode $mod+Shift+14 move container to workspace $WS5 317 bindcode $mod+Shift+15 move container to workspace $WS6 318 bindcode $mod+Shift+16 move container to workspace $WS7 319 bindcode $mod+Shift+17 move container to workspace $WS8 320 bindcode $mod+Shift+18 move container to workspace $WS9 321 bindcode $mod+Shift+19 move container to workspace $WS0 322 323 #assign [class="Firefox" window_role="browser"] → $WS1 324 #assign [class="Google-chrome" window_role="browser"] → $WS1 325 326 for_window [title="capture"] floating enable; 327 328 bindsym XF86MonBrightnessUp exec "xbacklight -inc 10" 329 bindsym XF86MonBrightnessDown exec "xbacklight -dec 10" 330 bindsym shift+XF86MonBrightnessUp exec "xbacklight -inc 1" 331 bindsym shift+XF86MonBrightnessDown exec "xbacklight -dec 1" 332 bindsym XF86AudioLowerVolume exec "pactl set-sink-mute @DEFAULT_SINK@ false ; pactl set-sink-volume @DEFAULT_SINK@ -5%" 333 bindsym XF86AudioRaiseVolume exec "pactl set-sink-mute @DEFAULT_SINK@ false ; pactl set-sink-volume @DEFAULT_SINK@ +5%" 334 bindsym XF86AudioMute exec "pactl set-sink-mute @DEFAULT_SINK@ toggle" 335 bindsym XF86AudioMicMute exec "pactl set-source-mute @DEFAULT_SOURCE@ toggle" 336 bindsym XF86AudioPlay exec "playerctl play-pause" 337 bindsym XF86AudioNext exec "playerctl next" 338 bindsym XF86AudioPrev exec "playerctl previous" 339 340 # reload the configuration file 341 bindsym $mod+Shift+x reload 342 # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) 343 bindsym $mod+Shift+o restart 344 # exit i3 (logs you out of your X session) 345 bindsym $mod+Shift+p exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3?' -b 'Yes, exit i3' 'i3-msg exit'" 346 # powermenu 347 bindsym $mod+F12 exec ${powermenu} 348 bindsym $mod+F10 exec ${pkgs.my.scripts}/bin/shot %d 349 bindsym $mod+Shift+F10 exec ${pkgs.my.scripts}/bin/shotf %d 350 351 # screen management 352 bindsym $mod+F11 exec "autorandr -c" 353 bindsym $mod+Shift+F11 exec "arandr" 354 355 # move workspace to output 356 set $workspace_move Move workspace to output : [l]eft [r]ight [d]own [u]p 357 358 mode "$workspace_move" { 359 bindsym left move workspace to output left 360 bindsym l move workspace to output left 361 362 bindsym right move workspace to output right 363 bindsym r move workspace to output right 364 365 bindsym down move workspace to output down 366 bindsym d move workspace to output down 367 368 bindsym up move workspace to output up 369 bindsym u move workspace to output up 370 371 bindsym Escape mode "default" 372 bindsym Return mode "default" 373 } 374 375 bindsym $mod+m mode "$workspace_move" 376 377 # resize window (you can also use the mouse for that) 378 mode "resize" { 379 # These bindings trigger as soon as you enter the resize mode 380 381 # Pressing left will shrink the window’s width. 382 # Pressing right will grow the window’s width. 383 # Pressing up will shrink the window’s height. 384 # Pressing down will grow the window’s height. 385 bindsym t resize shrink width 10 px or 10 ppt 386 bindsym s resize grow height 10 px or 10 ppt 387 bindsym r resize shrink height 10 px or 10 ppt 388 bindsym n resize grow width 10 px or 10 ppt 389 390 # same bindings, but for the arrow keys 391 bindsym Left resize shrink width 10 px or 10 ppt 392 bindsym Down resize grow height 10 px or 10 ppt 393 bindsym Up resize shrink height 10 px or 10 ppt 394 bindsym Right resize grow width 10 px or 10 ppt 395 396 # back to normal: Enter or Escape 397 bindsym Return mode "default" 398 bindsym Escape mode "default" 399 } 400 401 bindsym $mod+o mode "resize" 402 ## quick terminal (tmux) 403 exec --no-startup-id kitty --title metask --class metask tmux 404 exec --no-startup-id emacsclient -n -c -F "((name . \"_emacs scratchpad_\"))" 405 for_window [instance="metask"] floating enable; 406 for_window [instance="metask"] move scratchpad; [instance="metask"] scratchpad show; move position center; move scratchpad 407 bindcode $mod+49 [instance="metask"] scratchpad show 408 409 bindcode $mod+51 [class="Spotify"] scratchpad show 410 bindcode $mod+23 move scratchpad 411 412 exec --no-startup-id emacsclient -n -c -F "((name . \"_emacs scratchpad_\"))" 413 for_window [title="_emacs scratchpad_" class="Emacs"] move scratchpad 414 bindcode $mod+Shift+49 [title="_emacs scratchpad_" class="Emacs"] scratchpad show 415 416 # System menu 417 set $sysmenu "system: [s]uspend [l]ock [r]estart [b]lank-screen [p]oweroff reload-[c]onf e[x]it" 418 bindsym $mod+q mode $sysmenu 419 mode $sysmenu { 420 # restart i3 inplace (preserves your layout/session) 421 bindsym s exec ~/.i3/status_scripts/ambisleep; mode "default" 422 bindsym l exec i3lock -c 5a5376; mode "default" 423 bindsym r restart 424 bindsym b exec "xset dpms force off"; mode "default" 425 bindsym p exec systemctl shutdown 426 bindsym c reload; mode "default" 427 bindsym x exit 428 bindsym Return mode "default" 429 bindsym Escape mode "default" 430 bindsym $mod+q mode "default" 431 } 432 ''; 433 }; 434 # FIXME switch to polybar ? 435 xdg.configFile."i3status/config".text = '' 436 # i3status configuration file. 437 # see "man i3status" for documentation. 438 439 # It is important that this file is edited as UTF-8. 440 # The following line should contain a sharp s: 441 # ß 442 # If the above line is not correctly displayed, fix your editor first! 443 444 general { 445 colors = true 446 interval = 2 447 } 448 449 order += "path_exists 🔑" 450 order += "battery 0" 451 order += "load" 452 order += "tztime local" 453 454 battery 0 { 455 format = "%status %percentage %remaining" 456 format_down = "No battery" 457 status_chr = "⚇" 458 status_bat = "⚡" 459 status_full = "☻" 460 status_unk = "?" 461 path = "/sys/class/power_supply/BAT%d/uevent" 462 low_threshold = 10 463 } 464 465 run_watch 🐳 { 466 pidfile = "/run/docker.pid" 467 } 468 469 path_exists 🔑 { 470 path = "/proc/sys/net/ipv4/conf/wg0" 471 } 472 473 tztime local { 474 format = "%Y-%m-%d %H:%M:%S" 475 } 476 477 load { 478 format = "%1min" 479 } 480 481 cpu_temperature 0 { 482 format = "T: %degrees °C" 483 path = "/sys/class/hwmon/hwmon0/temp1_input" 484 } 485 486 disk "/" { 487 format = "%avail" 488 } 489 ''; 490 }