Created
June 25, 2023 17:35
-
-
Save Omrigan/858d1f504b8518714af9b57504352d94 to your computer and use it in GitHub Desktop.
Sway & I3 config template
This file contains 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
common = """ | |
exec_always pactl load-module module-switch-on-connect | |
set $mod Mod4 | |
floating_modifier $mod | |
font pango:monospace 12 | |
# output * { | |
# bg ~/box/picture/wallpaper.jpg stretch | |
# } | |
workspace_layout tabbed | |
bindsym $mod+Return exec wezterm start --always-new-process | |
# bindsym # $mod+Return exec wezterm start | |
# bindsym # $mod+Return exec st | |
# bindsym # $mod+Return exec qterminal | |
# bindsym # $mod+Return exec kitty | |
# bindsym #bindsym $mod+Return exec terminator | |
# bindsym # bindsym $mod+Return exec gnome-terminal | |
# bindsym #bindsym $mod+Return exec urxvt | |
# bindsym #bindsym $mod+Return exec termite | |
# bindsym #bindsym $mod+Return exec i3-sensible-terminal | |
bindsym $mod+d exec rofi -show combi | |
# bindsym #$mod+d exec dmenu_run -fn 14:monospace | |
# bindsym #$mod+d exec wofi -S run | |
bindsym $mod+i exec clipman pick --tool=wofi --max-items=99 | |
bindsym $mod+n exec lock.sh | |
# change focus | |
bindsym $mod+h focus left | |
bindsym $mod+j focus down | |
bindsym $mod+k focus up | |
bindsym $mod+l focus right | |
# alternatively, you can use the cursor keys: | |
bindsym $mod+Left focus left | |
bindsym $mod+Down focus down | |
bindsym $mod+Up focus up | |
bindsym $mod+Right focus right | |
# move focused window | |
bindsym $mod+Shift+h move left | |
bindsym $mod+Shift+j move down | |
bindsym $mod+Shift+k move up | |
bindsym $mod+Shift+l move right | |
# alternatively, you can use the cursor keys: | |
bindsym $mod+Shift+Left move left | |
bindsym $mod+Shift+Down move down | |
bindsym $mod+Shift+Up move up | |
bindsym $mod+Shift+Right move right | |
bindsym $mod+Control+Shift+Right move workspace to output right | |
bindsym $mod+Control+Shift+Left move workspace to output left | |
bindsym $mod+Control+Shift+Down move workspace to output down | |
bindsym $mod+Control+Shift+Up move workspace to output up | |
# Volume hotkey | |
bindsym $mod+z exec pulsemixer --change-volume -5 | |
bindsym $mod+x exec pulsemixer --change-volume +5 | |
bindsym $mod+c exec pulsemixer --toggle-mute | |
bindsym XF86AudioRaiseVolume exec pulsemixer --change-volume +5 | |
bindsym XF86AudioLowerVolume exec pulsemixer --change-volume -5 | |
bindsym XF86AudioMute exec pulsemixer --toggle-mute | |
# XF86PowerOff input 1:1:AT_Translated_Set_2_keyboard events toggle; | |
bindsym XF86MonBrightnessUp exec b.sh 10+ # increase screen brightness | |
bindsym XF86MonBrightnessDown exec b.sh 10- # decrease screen brightness | |
bindsym Print exec grabsway | |
# split in horizontal orientation | |
bindsym $mod+b split h | |
# split in vertical orientation | |
bindsym $mod+v split v | |
# enter fullscreen mode for the focused container | |
bindsym $mod+f fullscreen toggle | |
# change container layout (stacked, tabbed, toggle split) | |
bindsym $mod+s layout toggle split | |
bindsym $mod+t layout tabbed | |
bindsym $mod+w layout stacked | |
bindsym $mod+p focus parent | |
bindsym $mod+semicolon focus child | |
bindsym $mod+bracketright nop top_next | |
bindsym $mod+bracketleft nop top_prev | |
bindsym $mod+minus focus prev | |
bindsym $mod+equal focus next | |
# toggle tiling / floating | |
bindsym $mod+Shift+space floating toggle | |
# change focus between tiling / floating windows | |
bindsym $mod+space focus mode_toggle | |
bindsym $mod+Shift+q kill | |
bindsym $mod+u [urgent=latest] focus | |
bindsym $mod+1 workspace 1 | |
bindsym $mod+2 workspace 2 | |
bindsym $mod+3 workspace 3 | |
bindsym $mod+4 workspace 4 | |
bindsym $mod+5 workspace 5 | |
bindsym $mod+6 workspace 6 | |
bindsym $mod+7 workspace 7 | |
bindsym $mod+8 workspace 8 | |
bindsym $mod+9 workspace 9 | |
bindsym $mod+0 workspace 10 | |
bindsym $mod+Shift+1 move container to workspace 1 | |
bindsym $mod+Shift+2 move container to workspace 2 | |
bindsym $mod+Shift+3 move container to workspace 3 | |
bindsym $mod+Shift+4 move container to workspace 4 | |
bindsym $mod+Shift+5 move container to workspace 5 | |
bindsym $mod+Shift+6 move container to workspace 6 | |
bindsym $mod+Shift+7 move container to workspace 7 | |
bindsym $mod+Shift+8 move container to workspace 8 | |
bindsym $mod+Shift+9 move container to workspace 9 | |
bindsym $mod+Shift+0 move container to workspace 10 | |
bindsym $mod+F1 workspace f1 | |
bindsym $mod+F2 workspace f2 | |
bindsym $mod+F3 workspace f3 | |
bindsym $mod+Shift+F1 move container to workspace f1 | |
bindsym $mod+Shift+F2 move container to workspace f2 | |
bindsym $mod+Shift+F3 move container to workspace f3 | |
bindsym $mod+m workspace "media" | |
bindsym $mod+Shift+m move container to workspace "media" | |
bindsym $mod+g workspace "game" | |
bindsym $mod+Shift+g move container to workspace "game" | |
# resize window (you can also use the mouse for that) | |
mode "resize" { | |
# These bindings trigger as soon as you enter the resize mode | |
# Pressing left will shrink the window’s width. | |
# Pressing right will grow the window’s width. | |
# Pressing up will shrink the window’s height. | |
# Pressing down will grow the window’s height. | |
bindsym h resize shrink width 10 px or 10 ppt | |
bindsym j resize shrink height 10 px or 10 ppt | |
bindsym k resize grow height 10 px or 10 ppt | |
bindsym l resize grow width 10 px or 10 ppt | |
# same bindings, but for the arrow keys | |
bindsym Left resize shrink width 10 px or 10 ppt | |
bindsym Down resize grow height 10 px or 10 ppt | |
bindsym Up resize shrink height 10 px or 10 ppt | |
bindsym Right resize grow width 10 px or 10 ppt | |
# back to normal: Enter or Escape | |
bindsym Return mode "default" | |
bindsym Escape mode "default" | |
} | |
bindsym $mod+r mode "resize" | |
bar { | |
font pango:DejaVu Sans Mono, FontAwesome 12 | |
# status_command py3status | |
#status_command while ~/scripts/sway_bar.sh; do sleep 1; done | |
#status_command sway_bar.sh | |
swaybar_command waybar | |
#status_command i3status | |
#status_command i3status-rs ~/.config/i3status/config-rs.toml | |
#status_command i3blocks | |
#position top | |
#colors { | |
#statusline #ffffff | |
#background #000000AA | |
#inactive_workspace #323232AA #323232AA #5c5c5cAA | |
#} | |
#colors { | |
#separator #666666 | |
#background #222222 | |
#statusline #dddddd | |
#focused_workspace #0088CC #0088CC #ffffff | |
#active_workspace #333333 #333333 #ffffff | |
#inactive_workspace #333333 #333333 #888888 | |
#urgent_workspace #2f343a #900000 #ffffff | |
#} | |
} | |
""" | |
epilogue = """ | |
workspace f1 output $maino | |
workspace f2 output HEADLESS-1 | |
workspace f3 output HEADLESS-2 | |
""" | |
import os | |
def write_sway(): | |
global common | |
code = common | |
if os.environ["HOSTNAME"] == "dv": | |
code += """ | |
set $maino eDP-1 | |
output $maino { | |
position 1920 0 | |
# position 0 0 | |
scale 1.5 | |
} | |
output HEADLESS-1 { | |
# position 2048 0 | |
position 0 0 | |
} | |
""" | |
if os.environ["HOSTNAME"] == "kolobok": | |
code += """ | |
set set $maino eDP-1 $maino eDP-1 | |
stZZ: | |
output $maino { | |
position 1920 0 | |
# position 0 0 | |
scale 1.5 | |
} | |
""" | |
code = code.replace("bindsym", "bindsym --to-code") | |
code += """ | |
for_window [app_id="^.*"] inhibit_idle fullscreen | |
for_window [class="^.*"] inhibit_idle fullscreen | |
input * { | |
xkb_layout us,ru | |
xkb_options caps:none | |
# xkb_options grp:caps_toggle | |
} | |
# exec_always pulseaudio --start | |
# exec_always bluetooth-poweron.sh | |
exec_always blueman-manager | |
exec_always yandex-disk start | |
exec_always dbus-update-activation-environment --all | |
exec_always systemctl --user import-environment | |
exec_always systemctl --user restart monitor | |
exec_always systemctl --user restart sway-session.target | |
exec WAYLAND_DEBUG=1 wezterm | |
bindsym Shift_R input "*" xkb_switch_layout 1 | |
bindsym VoidSymbol input "*" xkb_switch_layout 0 | |
bindsym $mod+Shift+r reload | |
bindsym $mod+Shift+e exec "swaynag -t warning -m 'Exit?' -b 'Yes' 'swaymsg exit'" | |
""" | |
code += epilogue | |
with open(os.environ["HOME"] + "/.config/sway/config", "w") as f: | |
f.write(code) | |
def write_i3(): | |
code = common | |
code += """ | |
bindsym $mod+Shift+r restart | |
bindsym $mod+Shift+e exit | |
exec_always setxkbmap -option grp:caps_toggle us,ru grp:caps_toggle | |
exec dunst | |
exec xxkb | |
""" | |
code += epilogue | |
with open(os.environ["HOME"] + "/.config/i3/config", "w") as f: | |
f.write(code) | |
if __name__ == "__main__": | |
write_sway() | |
write_i3() | |
# Home | |
# set $mon1 'Lenovo Group Limited LEN T24i-10 VNA43CPB' | |
# set $mon2 'Lenovo Group Limited LEN T24i-10 VNA41PFG' | |
# output $mon1 { | |
# position 1920 0 | |
# } | |
# output $mon2 { | |
# position 3840 540 | |
# } | |
# workspace 1 output $mon1 | |
# workspace 4 output $mon1 | |
# workspace media output $mon1 | |
# workspace game output $mon1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment