Created
January 20, 2019 01:05
-
-
Save goose121/3c1966ce0e93fc1842e24fc271dffbc1 to your computer and use it in GitHub Desktop.
i3 configuration using Scribble
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang scribble/text | |
| @(require racket threading "i3cfg.rkt") | |
| @; i3 config file (v4) | |
| @; | |
| @; Please see https://i3wm.org/docs/userguide.html for a complete reference! | |
| set $mod Mod4 | |
| @; Font for window titles. Will also be used by the bar unless a different font | |
| @; is used in the bar {} block below. | |
| @;font pango:monospace 8 | |
| font pango:Anonymous Pro 8 | |
| @; This font is widely installed, provides lots of unicode glyphs, right-to-left | |
| @; text rendering and scalability on retina/hidpi displays (thanks to pango). | |
| @;font pango:DejaVu Sans Mono 8 | |
| @; Before i3 v4.8, we used to recommend this one as the default: | |
| @; font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 | |
| @; The font above is very space-efficient, that is, it looks good, sharp and | |
| @; clear in small sizes. However, its unicode glyph coverage is limited, the old | |
| @; X core fonts rendering does not support right-to-left and this being a bitmap | |
| @; font, it doesn’t scale on retina/hidpi displays. | |
| @; Begin my config | |
| @(define signs '(+ -)) | |
| @for/l[([cmd '(pa-applet |compton -b|)])]{exec @cmd} | |
| @for/l[([cmd '(~/.config/i3/startup.sh |pulseaudio --start| |srandrd ~/.local/share/disphandler.sh|)])]{exec --no-startup-id @cmd} | |
| @for/l[ | |
| ( | |
| [mod '(|| Shift+ ||)] | |
| [keytype '(Mon Mon Kbd)] | |
| [dev '(screen screen keyboard)] | |
| [Δb '(375 75 1)] | |
| #:when #t | |
| [keydir '(Up Down)] | |
| [sign signs] | |
| ) | |
| ]{bindsym @|mod|XF86@|keytype|Brightness@keydir exec /usr/local/bin/priv/brightctl --@dev --inc @|sign|@Δb} | |
| @for/l[([keyop '(Raise Lower)] [sign signs])]{bindsym XF86Audio@|keyop|Volume exec ~/.local/bin/volctl 5%@sign} | |
| bindsym XF86AudioMute exec ~/.local/bin/volctl toggle | |
| bindsym $mod+comma move scratchpad | |
| bindsym $mod+period scratchpad show | |
| bindsym $mod+t exec termite --name="popup-term" | |
| @for/l[([cmd '(|floating enable| |border none|)])]{for_window [class="Termite" instance="popup-term"] @cmd} | |
| @; --geometry was removed so the window is instead resized by the wm | |
| @; see https://github.com/thestinger/termite/issues/590 | |
| @(define popup-term-w 80) | |
| @(define popup-term-h 10) | |
| for_window [class="Termite" instance="popup-term"] @; | |
| resize set @(~> popup-term-w (/ 80) (* 100) round) ppt @(~> popup-term-h (/ 24) (* 100) round) ppt | |
| @for/l[([key '(i z Shift+w)] | |
| [cmd '(i3-input i3lock i3-ws)])]{bindsym $mod+@key exec @cmd} | |
| @for/l[([mod '(|| Shift+ Mod1+)] | |
| [cmd '(workspace |move window to workspace| |rename workspace to|)])]{bindsym $mod+@|mod|n exec i3-input -F '@cmd "%s"'} | |
| @modeblock["launcher" | |
| "c"]{ | |
| @for/l[([key '(f b d e)] | |
| [cmd '(firefox /usr/local/bin/priv/bt-setup discord emacs)])]{bindsym @key exec @cmd @sc mode default} | |
| } | |
| @modeblock["dunst-ctl" | |
| "Shift+d"]{ | |
| @for/l[([key '(e d)] | |
| [sig '(2 1)])]{bindsym @key exec killall -USR@sig dunst @sc mode default} | |
| } | |
| @;set $dmenu-wrap ~/.local/share/dmenu-scripts/dmenu-wrap | |
| @;mode "dmenu" { | |
| @; bindsym d exec --no-startup-id i3-dmenu-desktop ; mode default | |
| @; bindsym !!f,e exec --no-startup-id $dmenu-wrap !!firefox,emacs ; mode default | |
| @; !@exitmode | |
| @; bindsym $mod+d mode default | |
| @;} | |
| @; | |
| bindsym $mod+d exec --no-startup-id i3-dmenu-desktop | |
| @; Timidity is best as a floating window | |
| for_window [class="TiMidity"] floating enable | |
| @; End my config | |
| @; Use Mouse+$mod to drag floating windows to their wanted position | |
| floating_modifier $mod | |
| @; start a terminal | |
| bindsym $mod+Return exec termite | |
| @; kill focused window | |
| bindsym $mod+Shift+q kill | |
| @; start dmenu (a program launcher) | |
| @; bindsym $mod+d exec dmenu_run | |
| @; There also is the (new) i3-dmenu-desktop which only displays applications | |
| @; shipping a .desktop file. It is a wrapper around dmenu, so you need that | |
| @; installed. | |
| @;bindsym $mod+d exec --no-startup-id i3-dmenu-desktop | |
| @; | |
| @(define dirkeys '(Left Down Up Right j k l semicolon)) | |
| @(define direc (cycle-match dirkeys '(left down up right))) | |
| @; change focus and move | |
| @for/l[([mod '(|| Shift+)] | |
| [cmd '(focus move)] | |
| #:when #t | |
| [dirkey dirkeys] | |
| [direc direc])]{bindsym $mod+@|mod|@dirkey @cmd @direc} | |
| @; split container | |
| @for/l[([s '(h v)])]{bindsym $mod+@s split @s} | |
| @; enter fullscreen mode for the focused container | |
| bindsym $mod+f fullscreen toggle | |
| @; change container layout (stacked, tabbed, toggle split) | |
| @for/l[([key '(s w e)] | |
| [lo '(stacking tabbed |toggle split|)])]{bindsym $mod+@key layout @lo} | |
| @; toggle tiling / floating | |
| bindsym $mod+Shift+space floating toggle | |
| @; change focus between tiling / floating windows | |
| bindsym $mod+space focus mode_toggle | |
| @; focus the parent container | |
| bindsym $mod+q focus parent | |
| @; focus the child container | |
| bindsym $mod+a focus child | |
| @; workspace stuff | |
| @for/l[([key (append (range 1 10) '(0))] | |
| [ws (range 1 11)])]{ | |
| bindsym $mod+@key workspace number @ws | |
| bindsym $mod+Shift+@key move container to workspace number @ws | |
| bindsym $mod+Mod1+@key rename workspace to @ws | |
| } | |
| @; reload the configuration file | |
| @for/l[([key '(c r)] | |
| [cmd '(reload restart)])]{bindsym $mod+Shift+@key exec "racket ~/.config/i3/config.scrbl > ~/.config/i3/config && ( sleep 0.5; i3-msg @cmd )"} | |
| @; exit i3 (logs you out of your X session) | |
| bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" | |
| @modeblock["resize" | |
| "r"]{ | |
| @for/l[([dirkeys dirkeys] | |
| [op (cycle-match dirkeys '(shrink grow shrink grow))] | |
| [dim (cycle-match dirkeys '(width height height width))] | |
| )]{bindsym @dirkeys resize @op @dim 10px or 10ppt} | |
| } | |
| @; Start i3bar to display a workspace bar (plus the system information i3status | |
| @; finds out, if available) | |
| bar { | |
| status_command i3blocks | |
| workspace_buttons yes | |
| tray_padding 0 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang at-exp racket | |
| (require threading (for-syntax syntax/parse racket)) | |
| (provide for/l cycle-to cycle-match sc modeblock) | |
| ; Appends all of the strings produced by the body statements on each | |
| ; iteration, and joins the produced strings with newlines | |
| (define-syntax (for/l stx) | |
| (syntax-case stx () | |
| [(_ clauses body ... tail-expr) | |
| (with-syntax ([orig stx]) | |
| #'(for/fold/derived | |
| orig | |
| ([accum '()] | |
| #:result (add-between accum "\n")) | |
| clauses | |
| (append accum (list (string-append (~a body) ... (~a tail-expr)))) | |
| ) | |
| ) | |
| ] | |
| ) | |
| ) | |
| ; Returns a list of length n constructed by cycling through the | |
| ; elements of l | |
| (define (cycle-to n l) | |
| (build-list n (λ (n) (~>> (length l) (modulo n) (list-ref l)))) | |
| ) | |
| ; Returns a list with the same length as `orig` constructed by | |
| ; cycling through the elements of l | |
| (define (cycle-match orig l) | |
| (cycle-to (length orig) l) | |
| ) | |
| ; Semicolons mess up the emacs racket-mode by making it think that the | |
| ; rest of the line is a comment; when they appear in a text-block, and | |
| ; that text-block closes on the same line, the indentation will be | |
| ; messed up for the rest of the file. This define lets us avoid that | |
| ; by using @sc instead of a literal semicolon. | |
| (define sc ";") | |
| (define (modeblock name keybind . contents) | |
| (define chord (string-append "$mod+" keybind)) | |
| @list{ | |
| mode "@name" { | |
| @contents | |
| @for/l[([chord `(Escape Return ,chord)])]{bindsym @chord mode default} | |
| } | |
| bindsym @chord mode @name | |
| } | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment