Skip to content

Instantly share code, notes, and snippets.

@shikaan
Last active November 6, 2022 19:45
Show Gist options
  • Save shikaan/303fe7c69223fe288de983ae702eccb6 to your computer and use it in GitHub Desktop.
Save shikaan/303fe7c69223fe288de983ae702eccb6 to your computer and use it in GitHub Desktop.
sway + foot configurtaion
term=screen-256color
font=Fira Code,Noto Color Emoji:size=8
[cursor]
style=underline
# Solarized light
[cursor]
color=fdf6e3 586e75
[colors]
background= fdf6e3
foreground= 657b83
regular0= eee8d5
regular1= dc322f
regular2= 859900
regular3= b58900
regular4= 268bd2
regular5= d33682
regular6= 2aa198
regular7= 073642
bright0= cb4b16
bright1= fdf6e3
bright2= 93a1a1
bright3= 839496
bright4= 657b83
bright5= 6c71c4
bright6= 586e75
bright7= 002b36
#!/bin/env bash
CLIPBOARD=/tmp/clipboard
COUNT=10
touch $CLIPBOARD
wl-paste >> $CLIPBOARD
TMP=$(mktemp)
tac $CLIPBOARD | awk '!seen[$0]++' | tac | tail -n $COUNT > $TMP
rm $CLIPBOARD
mv $TMP $CLIPBOARD
### Variables
# Terminal
set $term foot
# Logo key. Use Mod1 for Alt.
set $mod Mod4
# Remove borders from terminals
for_window [app_id="foot"] border pixel
# Launcher
set $menu exec $term -T launcher bash -c "dmenu_path | fzf --layout=reverse | xargs swaymsg exec --"
for_window [title="^launcher$"] floating enable, border pixel
# Clipboard manager
exec wl-paste -w ~/.config/sway/clipboard.sh
set $clipboard exec $term -T clip -o colors.background=ffe4e1 -W 30x12 bash -c "tac /tmp/clipboard | fzf -1 --layout=reverse | wl-copy -n"
for_window [title="^clip$"] floating enable, border pixel
# Set Background
output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
font pango:Fira Code Medium 13
exec swayidle -w \
timeout 300 'swaylock -f -c 000000' \
timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f -c 000000'
input "2:7:SynPS/2_Synaptics_TouchPad" {
dwt enabled
tap enabled
natural_scroll disabled
middle_emulation enabled
tap_button_map lrm
}
### Keybindings
# Start terminal
bindsym Control+Alt+T exec $term
# Kill focused window
bindsym Alt+F4 kill
# Start your launcher
bindsym Alt+Space exec $menu
# Start clipboard manager
bindsym Control+H exec $clipboard
# Reload the configuration file
bindsym $mod+Shift+c reload
# Exit sway (logs you out of your Wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'
# Move windows across workspaces
bindsym Control+Shift+Alt+Left move container to workspace next, workspace next
bindsym Control+Shift+Alt+Right move container to workspace prev, workspace next
# Cycle between workspaces
bindsym Control+Alt+Left workspace prev
bindsym Control+Alt+Right workspace next
# Switch to specific workspace (needed to create workspaces)
bindsym $mod+F1 workspace 1
bindsym $mod+Shift+F1 move window to workspace 1
bindsym $mod+F2 workspace 2
bindsym $mod+Shift+F2 move window to workspace 2
bindsym $mod+F3 workspace 3
bindsym $mod+Shift+F3 move window to workspace 3
bindsym $mod+F4 workspace 4
bindsym $mod+Shift+F4 move window to workspace 4
# Move focus among windows
bindsym Alt+Tab exec sway [con_id=$(swaymsg -t get_tree | ~/.config/sway/focus.js next)] focus
bindsym Alt+Shift+Tab exec sway [con_id=$(swaymsg -t get_tree | ~/.config/sway/focus.js prev)] focus
# Move tiles around
bindsym $mod+Down move down
bindsym $mod+Up move up
bindsym $mod+Left move left
bindsym $mod+Right move left
# Brightness
bindsym XF86MonBrightnessDown exec "light -U 5"
bindsym XF86MonBrightnessUp exec "light -A 5"
# Volume
bindsym XF86AudioLowerVolume exec "pactl set-sink-volume 0 -5%"
bindsym XF86AudioRaiseVolume exec "pactl set-sink-volume 0 +5%"
#
# Resizing containers:
#
mode "resize" {
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"
#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
bar {
position top
# When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time.
status_command while ~/.config/sway/status.sh; do sleep 1; done
icon_theme "Noto Color Emoji"
colors {
statusline #ffffff
background #323232
inactive_workspace #32323200 #32323200 #5c5c5c
}
}
#! /bin/env node
process.stdin.once('data', (data) => {
const tree = JSON.parse(data.toString())
const nodes = getNodes(tree.nodes[1])
const focusedNodeIndex = nodes.findIndex(i => i.focused)
process.stdout.write(nodes[getNewIndex(focusedNodeIndex, nodes.length)].id.toString())
})
// Increment or decrement depending on the provided command
function getNewIndex(i, d) {
if (process.argv.includes('next')) {
return (i + 1 + d) % d
} else if (process.argv.includes('prev')) {
return (i - 1 + d) % d
}
return i
}
// Returns container nodes
function getNodes(tree) {
if (tree.nodes && tree.nodes.length > 0) {
const result = []
for ( const node of tree.nodes ) {
result.push(getNodes(node))
}
return result.flat().filter(i => i)
}
if (tree.type == 'con') {
return tree
}
return null
}
#! /bin/bash
get_volume() {
amixer -M get Master | grep -oE "[0-9]+%" | head -n 1
}
volume_icon="🔉"
get_date() {
date +'%a %b %d %H:%M'
}
get_wifi_ssid() {
iwconfig | grep ESSID | sed -e 's/.*ESSID:"\(.*\)".*/\1/'
}
wifi_icon="📶"
get_brightness() {
light | awk '{printf "%d%s", $1, "%" }'
}
brightness_icon="🔆"
while :
do
volume=$(get_volume)
date=$(get_date)
wifi_ssid=$(get_wifi_ssid)
brightness=$(get_brightness)
echo "$wifi_icon $wifi_ssid $volume_icon $volume $brightness_icon $brightness | $date "
sleep 1
done

Sway + foot configuration

It's based on a fresh Debian bookworm install. Replace the _ with / in the filenames for the complete paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment