Commit 9019a960 authored by peacerebel's avatar peacerebel
Browse files

Add sway, swaylock, swayr and waybar config

parent 92221110
# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.
### Variables
#
# Logo key. Use Mod1 for Alt.
set $alt Mod1
set $mod Mod4
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
# Font
font pango:Hack, Font Awesome 5 Free 10
# Your preferred terminal emulator
set $term terminator
# Your preferred application launcher
# Note: pass the final command to swaymsg so that the resulting window can be opened
# on the original workspace that the command was run on.
set $menu rofi -show drun
### Output configuration
#
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
output * bg ~/Pictures/mgi2to3r94461.png fill
# Window colors
# Class border Backgr Text indicator child_border
client.focused #555555 #555555 #ffffff #0066ff #ffffff
client.unfocused #222222 #222222 #dddddd #4080bf #4080bf
client.urgent #2f343a #900000 #ffffff #900000
# Gaps
gaps inner 2
gaps outer 1
default_border none
focus_follows_mouse yes
# Window rules
#==== Disable window border ===
for_window [class="^.*"] border pixel 0
for_window [app_id="^.*"] border pixel 0
# browser pop-ups
for_window [window_role="pop-up"] floating enable
### Idle configuration
exec swayidle -w \
timeout 2520 'swaylock -f -C ~/.config/swaylock/config' \
timeout 2800 'systemctl suspend' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f -C ~/.config/swaylock/config'
### Input configuration
input type:touchpad {
dwt enabled
tap enabled
drag enabled
natural_scroll enabled
middle_emulation enabled
}
### Key bindings
#
# Basics:
#
# Start a terminal
bindsym $mod+Return exec $term
# list open windows to switch to
bindsym $alt+Tab exec env RUST_BACKTRACE=1 \
swayr switch-window >> /tmp/swayr.log 2>&1
# Kill focused window
bindsym $mod+Shift+q kill
# Start your launcher
bindsym $mod+d exec $menu
# Drag floating windows by holding down $mod and left mouse button.
# Resize them with right mouse button + $mod.
# Despite the name, also works for non-floating windows.
# Change normal to inverse to use left mouse button for resizing and right
# mouse button for dragging.
floating_modifier $mod normal
# Reload the configuration file
bindsym $mod+Shift+r reload
# Exit sway (logs you out of your Wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'Exit sway?' -B 'Yes, logout' 'swaymsg exit'
#
# Moving around:
#
# Move your focus around
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
# Or use $mod+[up|down|left|right]
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# Move the focused window with the same, but add Shift
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
# Ditto, with arrow 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
#
# Workspaces:
#
set $ws1 Coding
set $ws2 Browse
set $ws3 Chat
set $ws4 Terminal
set $ws5 Office
set $ws6 A/V
set $ws7 Gaming
set $ws8 Downloads
set $ws9 Mail
#Assigning programs to workspaces
assign [class="(?i)terminator"] $ws4
for_window [class="(?i)terminator"] focus
assign [class="(?i)emacs"] $ws1
for_window [class="(?i)emacs"] focus
assign [class="(?i)firefox"] $ws2
for_window [class="(?i)firefox"] focus
assign [class="(?i)tor browser"] $ws2
for_window [class="(?i)tor browser"] focus
assign [class="(?i)transmission"] $ws8
for_window [class="(?i)transmission"] focus
assign [class="(?i)clementine"] $ws6
for_window [class="(?i)clemetine"] focus
assign [class="(?i)vlc"] $ws6
for_window [class="(?i)vlc"] focus
assign [class="(?i)Element"] $ws3
for_window [class="(?i)Element"] focus
assign [class="(?i)thunderbird"] $ws9
for_window [class="(?i)thunderbird"] focus
assign [class="(?i)libreoffice"] $ws5
for_window [class="(?i)libreoffice"] focus
assign [class="(?i)evince"] $ws5
for_window [class="(?i)evince"] focus
assign [class="(?i)steam"] $ws7
for_window [class="(?i)steam"] focus
for_window [class="(?i)Yad"] floating enable
# Switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Tab workspace back_and_forth
#
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+b or $mod+v, for horizontal and vertical splits
# respectively.
bindsym $mod+b splith
bindsym $mod+v splitv
# Switch the current container between different layout styles
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# Make the current focus fullscreen
bindsym $mod+f fullscreen
# Toggle the current focus between tiling and floating mode
bindsym $mod+Shift+space floating toggle
# Swap focus between the tiling area and the floating area
bindsym $mod+space focus mode_toggle
# Move focus to the parent container
bindsym $mod+a focus parent
#
# Scratchpad:
#
# Sway has a "scratchpad", which is a bag of holding for windows.
# You can send windows there and get them back later.
# Move the currently focused window to the scratchpad
bindsym $mod+Shift+minus move scratchpad
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
bindsym $mod+minus scratchpad show
#
# Resizing containers:
#
mode "resize" {
# left will shrink the containers width
# right will grow the containers width
# up will shrink the containers height
# down will grow the containers height
bindsym $left resize shrink width 10px
bindsym $down resize grow height 10px
bindsym $up resize shrink height 10px
bindsym $right resize grow width 10px
# Ditto, with arrow keys
bindsym Left resize shrink width 10px
bindsym Down resize grow height 10px
bindsym Up resize shrink height 10px
bindsym Right resize grow width 10px
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# Exit key binding
set $mode_system System (l) lock, (e) logout, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
bindsym l exec --no-startup-id ~/.config/sway/exit.sh lock, mode "default"
bindsym e exec --no-startup-id ~/.config/sway/exit.sh logout, mode "default"
bindsym h exec --no-startup-id ~/.config/sway/exit.sh hibernate, mode "default"
bindsym r exec --no-startup-id ~/.config/sway/exit.sh reboot, mode "default"
bindsym Shift+s exec --no-startup-id ~/.config/sway/exit.sh shutdown, mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+Delete mode "$mode_system"
# Lock screen
bindsym $mod+z exec swaylock -C ~/.config/swaylock/config
# Screenshot
set $scrot_full grim -t png ~/Pictures/screenshot-$(date +%Y-%m-%d_%H-%m-%s).jpg
set $scrot_region grim -t png -g "$(slurp)" ~/Pictures/screenshot-$(date +%Y-%m-%d_%H-%m-%s).jpg
set $mode_screenshot Screenshot (Enter), Full Screenshot, (S) Select Region
mode "$mode_screenshot" {
bindsym Return exec --no-startup-id $scrot_full && notify-send -t 2000 "Screenshot saved in your Pictures folder", mode "default"
bindsym --release s exec --no-startup-id $scrot_region && notify-send -t 2000 "Screenshot saved in your Pictures folder", mode "default"
bindsym Escape mode "default"
}
bindsym Print mode "$mode_screenshot"
# Bind music keys in keyboard to media control
#bindsym XF86AudioMute exec "pactl set-sink-mute 0 toggle && pkill -SIGRTMIN+10 i3blocks"
#bindsym XF86AudioRaiseVolume exec "pactl set-sink-volume 0 +5% && pkill -SIGRTMIN+10 i3blocks"
#bindsym XF86AudioLowerVolume exec "pactl set-sink-volume 0 -5% && pkill -SIGRTMIN+10 i3blocks"
#bindsym XF86AudioLowerVolume exec --no-startup-id "pactl set-sink-volume 0 -5%"
bindsym XF86AudioLowerVolume exec --no-startup-id "amixer set Master 5%- unmute"
#bindsym XF86AudioRaiseVolume exec --no-startup-id "pactl set-sink-volume 0 +5%"
bindsym XF86AudioRaiseVolume exec --no-startup-id "amixer set Master 5%+ unmute"
#bindsym XF86AudioMute exec --no-startup-id "pactl set-sink-mute 0 toggle"
bindsym XF86AudioMute exec --no-startup-id "amixer set Master toggle"
#Thinkpad Mic On/Off
bindsym XF86AudioMicMute exec --no-startup-id "amixer set Capture toggle"
#bindsym XF86AudioMicMute exec --no-startup-id "pactl set-source-mute 1 toggle"
#Brightness control using light
bindsym XF86MonBrightnessUp exec light -A 5
bindsym XF86MonBrightnessDown exec light -U 5
#Bright control using xbacklight
#bindsym XF86MonBrightnessUp exec xbacklight -inc 5
#bindsym XF86MonBrightnessDown exec xbacklight -dec 5
#Brightness control using light
#bindsym $mod+XF86MonBrightnessUp exec --no-startup-id "brightnessctl --device='tpacpi::kbd_backlight' set 50%+"
#bindsym $mod+XF86MonBrightnessDown exec --no-startup-id "brightnessctl --device='tpacpi::kbd_backlight' set 50%-"
#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
bar swaybar_command waybar
exec --no-startup-id nm-applet
include ~/.config/sway/config.d/*
include /etc/sway/config.d/*
# Start swayr
exec env RUST_BACKTRACE=1 RUST_LOG=swayr=debug swayrd > /tmp/swayrd.log 2>&1
#!/bin/sh
lock() {
i3lock
}
case "$1" in
lock)
i3lock-fancy -g
;;
logout)
i3-msg exit
;;
suspend)
lock && systemctl suspend
;;
hibernate)
lock && systemctl hibernate
;;
reboot)
systemctl reboot
;;
shutdown)
systemctl poweroff
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
exit 2
esac
exit 0
# Image
image=~/Pictures/srinivasan-venkataraman-9NmYCjfBGp0-unsplash.jpg
scaling=fill
# Indicator
indicator-caps-lock
# Behavior
show-failed-attempts
[menu]
executable = 'wofi'
args = [
'--show=dmenu',
'--allow-markup',
'--allow-images',
'--insensitive',
'--cache-file=/dev/null',
'--parse-search',
'--height=25%',
'--prompt={prompt}',
]
[format]
output_format = '{indent}<b>Output {name}</b> <span alpha="20000">({id})</span>'
workspace_format = '{indent}<b>Workspace {name} [{layout}]</b> on output {output_name} <span alpha="20000">({id})</span>'
container_format = '{indent}<b>Container [{layout}]</b> <i>{marks}</i> on workspace {workspace_name} <span alpha="20000">({id})</span>'
window_format = 'img:{app_icon}:text:{indent}<i>{app_name}</i> — {urgency_start}<b>“{title}”</b>{urgency_end} <i>{marks}</i> on workspace {workspace_name} / {output_name} <span alpha="20000">({id})</span>'
indent = ' '
urgency_start = '<span background="darkred" foreground="yellow">'
urgency_end = '</span>'
html_escape = true
icon_dirs = [
'/usr/share/icons/hicolor/scalable/apps',
'/usr/share/icons/hicolor/64x64/apps',
'/usr/share/icons/hicolor/48x48/apps',
'/usr/share/icons/Adwaita/64x64/apps',
'/usr/share/icons/Adwaita/48x48/apps',
'/usr/share/pixmaps',
]
[layout]
auto_tile = false
auto_tile_min_window_width_per_output_width = [
[
800,
400,
],
[
1024,
500,
],
[
1280,
600,
],
[
1400,
680,
],
[
1440,
700,
],
[
1600,
780,
],
[
1920,
920,
],
[
2560,
1000,
],
[
3440,
1000,
],
[
4096,
1200,
],
]
[focus]
lockin_delay = 750
{
"layer": "top",
"position": "bottom",
"height": 25,
"spacing": 2,
"modules-left": [
"sway/workspaces"
],
"modules-center": [
"sway/window"
],
"modules-right": [
"backlight",
"pulseaudio",
"network",
"cpu",
"memory",
"temperature",
"battery#bat0",
"battery#bat1",
"clock",
"sway/language",
"tray"
],
"tray": {
"icon-size": 20,
"spacing": 5
},
"clock": {
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
"format-alt": "{:%d, %b %Y}",
},
"cpu": {
"interval": 10,
"format": "{usage}% "
},
"memory": {
"interval": 10,
"format": "{}% "
},
"temperature": {
"critical-threshold": 80,
"format-critical": "{temperatureC}°C {icon}",
"format": "{temperatureC}°C {icon}",
"format-icons": ["", "", ""]
},
"backlight": {
"format": "{percent}% {icon}",
"format-icons": [ "🌑", "🌒", "🌓", "🌔", "🌕" ]
},
"battery": {
"states": {
"warning": 30,
"critical": 15
},
"format": "{capacity}% {icon}",
"format-charging": "{capacity}% ",
"format-plugged": "{capacity}% ",
"format-alt": "{time} {icon}",
"format-icons": ["", "", "", "", ""]
},
"battery#bat0": {
"bat": "BAT0"
},
"battery#bat1": {
"bat": "BAT1"
},
"network": {
"format-wifi": "{essid} ({signalStrength}%) ",
"format-ethernet": "{ipaddr}/{cidr} ",
"tooltip-format": "{ifname} via {gwaddr} ",
"format-linked": "{ifname} (No IP) ",
"format-disconnected": "Disconnected ⚠",
"format-alt": "{ifname}: {ipaddr}/{cidr}"
},
"pulseaudio": {
"format": "{volume}% {icon} {format_source}",
"format-bluetooth": "{volume}% {icon} {format_source}",
"format-bluetooth-muted": " {icon} {format_source}",
"format-muted": " {format_source}",
"format-source": "{volume}% ",
"format-source-muted": "",
"format-icons": {
"headphone": "",
"hands-free": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", "", ""]
},
"on-click": "pavucontrol"
}
}
{
"layer": "top", // Waybar at top layer
"position": "bottom", // Waybar position (top|bottom|left|right)
"height": 25, // Waybar height (to be removed for auto height)
//"width": 1280, // Waybar width
"spacing": 2, // Gaps between modules (4px)
// Choose the order of the modules
"modules-left": [
"sway/workspaces"
// "sway/mode",
// "custom/media"
],
"modules-center": [
"sway/window"
],
"modules-right": [
//"mpd",
//"idle_inhibitor",
"backlight",
"pulseaudio",
"network",
"cpu",
"memory",
"temperature",
//"keyboard-state",
"battery",
//"battery#bat2",
"clock",
"sway/language",
"tray"
],
// Modules configuration
// "sway/workspaces": {
// "disable-scroll": true,
// "all-outputs": true,
// "format": "{name}: {icon}",
// "format-icons": {
// "1": "",
// "2": "",
// "3": "",
// "4": "",
// "5": "",
// "urgent": "",
// "focused": "",
// "default": ""
// }
// },
// "keyboard-state": {
// "numlock": true,
// "capslock": true,
// "format": "{name} {icon}",
// "format-icons": {
// "locked": "",
// "unlocked": ""
// }
// },
// "sway/mode": {
// "format": "<span style=\"italic\">{}</span>"
// },
// "mpd": {
// "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ",
// "format-disconnected": "Disconnected ",
// "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ",
// "unknown-tag": "N/A",
// "interval": 2,
// "consume-icons": {
// "on": " "
// },
// "random-icons": {
// "off": "<span color=\"#f53c3c\"></span> ",
// "on": " "
// },
// "repeat-icons": {
// "on": " "
// },
// "single-icons": {
// "on": "1 "
// },
// "state-icons": {
// "paused": "",
// "playing": ""
// },
// "tooltip-format": "MPD (connected)",
// "tooltip-format-disconnected": "MPD (disconnected)"
// },
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "",
"deactivated": ""
}
},
"tray": {
// "icon-size": 21,
"spacing": 5