1
0
Fork 0

feat: add all configs

This commit is contained in:
Oliver Ladner 2025-10-05 14:14:45 +02:00
commit 0267199f6e
23 changed files with 1673 additions and 0 deletions

View file

@ -0,0 +1,222 @@
# Mod1 = Alt
# Mod4 = Windows key
set $mod Mod1
set $left h
set $down j
set $up k
set $right l
set $term alacritty
set $browser firefox
set $menu wmenu-run -i -p '>' -l 4 -f "BerkeleyMono Nerd Font Mono 12"
set $file thunar
set $ws1 1 web
set $ws2 2 term
set $ws3 3 file
set $ws4 4 blog
set $ws5 5 media
set $ws7 6 other
default_border pixel 5
default_floating_border pixel 5
gaps inner 8
# Hide border when only 1 window
hide_edge_borders smart
set {
$bg #243936
#$focused #ffde21
$text #c0c8c6
$active #66ac9f
}
# border background text indicator childborder
client.focused $bg $bg $text $active $active
output * bg ~/data/local/wallpaper/abstract.jpg fill
# output HDMI-A-1 resolution 1920x1080 position 1920,0
# You can get the names of your outputs by running: swaymsg -t get_outputs
# BSP-style window tiling
exec_always autotiling
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.
exec swayidle -w \
timeout 300 'swaylock -f -c 000000' \
timeout 330 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
before-sleep 'swaylock -f -c 000000'
# Clipboard manager
#exec wl-paste -t text --watch clipman store --no-persist
exec wl-paste --watch cliphist store
bindsym $mod+ctrl+v exec cliphist list | wmenu -l 3 | cliphist decode | wl-copy && wl-paste --no-newline | xargs -I {} wtype {}
# Notifications
### Input configuration
input type:keyboard {
xkb_layout "us"
xkb_variant intl
repeat_delay 250
repeat_rate 50
}
input type:pointer {
#accel_profile "flat" # disable mouse acceleration (enabled by default; to set it manually, use "adaptive" instead of "flat")
accel_profile "adaptive" # disable mouse acceleration (enabled by default; to set it manually, use "adaptive" instead of "flat")
pointer_accel -0.85 # set mouse sensitivity (between -1 and 1)
}
# Read `man 5 sway-input` for more information about this section.
### Key bindings
bindsym $mod+Return exec $term
bindsym $mod+G exec $browser
bindsym $mod+T exec $file
# 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+c reload
# Exit sway (logs you out of your Wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'
# Lock screen
bindsym $mod+o exec 'swaylock -f'
# Focus window
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
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+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# Switch 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
# 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 ctrl+alt+shift+n workspace next
bindsym ctrl+alt+shift+p workspace prev
# LAYOUT
# 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
# Zen mode
bindsym $mod+z floating toggle; resize set width 1750 height 1000; move position center
# 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
# XXX: what is this for
#bindsym $mod+a focus parent
# 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
bindsym ctrl+alt+shift+a resize shrink width 10px
bindsym ctrl+alt+shift+s resize grow height 10px
bindsym ctrl+alt+shift+w resize shrink height 10px
bindsym ctrl+alt+shift+d resize grow width 10px
# Resizing containers:
mode "RESIZE" {
bindsym $left resize shrink width 80px
bindsym $down resize grow height 20px
bindsym $up resize shrink height 20px
bindsym $right resize grow width 80px
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym ctrl+alt+shift+r mode "RESIZE"
# Volume control with PipeWire
# https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h
# Get the device ID with `wpctl status` or use @DEFAULT_AUDIO_SINK@
bindsym --locked XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindsym --locked XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.01-
bindsym --locked XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.01+
# FIXME: https://wiki.archlinux.org/title/MPRIS
# bindsym --locked XF86AudioPause exec wpctl set-mute 48 toggle
# Screenshot
bindsym Mod4+Shift+4 exec grimshot --notify save area
bindsym Mod4+Shift+Space exec grimshot --notify save window
# man 5 sway-bar
bar {
position bottom
font BerkeleyMono Nerd Font Mono
status_command ~/.config/sway/status.sh
colors {
statusline #869795
background #ffffff00
inactive_workspace #32323200 #32323200 #6c7e7c
focused_workspace #2d4844 #2d4844 #d5dad9
urgent_workspace #b4b479 #b4b479 #121c1b
}
}
for_window [title="galculator"] floating enable
include /etc/sway/config.d/*

184
home/oli/.config/sway/status.sh Executable file
View file

@ -0,0 +1,184 @@
#!/usr/bin/env bash
#
# Status bar for Sway
# Needs a .env.homeassistant with an API token in ~/.config/sway/.env.homeassistant
# XXX is it possible to display a motd, but keep it longer than the rest in here?
# TODO:
# - HA optimize API calls: https://community.home-assistant.io/t/get-limited-number-of-states-entities-when-using-api-states/830323
# man 7 swaybar-protocol
homeassistant_url="http://10.7.1.11:8123/api/states"
common() {
bg_ok="#66ac9f"
bg_ok_trans="#00000000"
text_dark="#36454f"
text_light="#c0c8c6"
warn1="#facc15"
warn2="#cc8d22"
crit="#710f3d"
. ~/.config/sway/.env.homeassistant
echo -n "{"
echo -n "\"separator_block_width\":10,"
echo -n "\"separator\":false,"
echo -n "\"color\":\"$fg\","
echo -n "\"background\":\"$bg\","
echo -n "\"name\":\"$name\","
echo -n "\"full_text\":\" $stat\","
echo -n "},"
}
temp_cpu() {
local name="cpu"
local cpu=$(expr $(cat /sys/class/thermal/thermal_zone2/temp) / 1000)
if [[ $(echo "$cpu >= 55" | bc -l ) == "1" ]] && [[ $(echo "$cpu < 65" | bc -l ) == "1" ]]; then
local bg=$warn1
local fg=$text_dark
elif [[ $(echo "$cpu >= 65" | bc -l ) == "1" ]] && [[ $(echo "$cpu < 75" | bc -l ) == "1" ]]; then
local bg=$warn2
local fg=$text_dark
elif [[ $(echo "$cpu >= 75" | bc -l ) == "1" ]]; then
local bg=$crit
local fg=$text_light
else
local bg=$bg_ok_trans
local fg=$text_light
fi
icon="󰍛"
local stat=$icon\ $cpu\ °C" "
common
}
mem(){
local name="mem"
local memused=$(free | grep Mem | awk '{printf "%.1f\n", $3/$2 * 100.0}')
local memproc=$(basename "$(ps --no-headers -A --sort -rss -o cmd | head -1 | awk {'print $1'})")
if [[ $(echo "$memused >= 50" | bc -l ) == "1" ]] && [[ $(echo "$memused < 60" | bc -l ) == "1" ]]; then
local bg=$warn1
local fg=$text_dark
elif [[ $(echo "$memused >= 60" | bc -l ) == "1" ]] && [[ $(echo "$memused < 70" | bc -l ) == "1" ]]; then
local bg=$warn2
local fg=$text_dark
elif [[ $(echo "$memused >= 70" | bc -l ) == "1" ]]; then
local bg=$crit
local fg=$text_light
else
local bg=$bg_ok_trans
local fg=$text_light
fi
icon=""
local stat=$icon\ $memused\ %\ [$memproc]" "
common
}
wifi() {
local name="wifi"
# orig = negative number
local wifidbm_orig=$(iwctl station wlan0 show | awk '/[[:space:]]RSSI/{print $2}')
local wifidbm=$((wifidbm_orig * -1))
if [[ $(echo "$wifidbm >= 50" | bc -l ) == "1" ]] && [[ $(echo "$wifidbm < 60" | bc -l ) == "1" ]]; then
local bg=$warn1
local fg=$text_dark
elif [[ $(echo "$wifidbm >= 60" | bc -l ) == "1" ]] && [[ $(echo "$wifidbm < 70" | bc -l ) == "1" ]]; then
local bg=$warn2
local fg=$text_dark
elif [[ $(echo "$wifidbm >= 70" | bc -l ) == "1" ]]; then
local bg=$crit
local fg=$text_light
else
local bg=$bg_ok_trans
local fg=$text_light
fi
icon=""
local stat=$icon\ -$wifidbm\ dBm" "
common
}
mydate() {
local bg=$bg_ok_trans
local fg=$bg_ok
local name="id_time"
local icon=""
local stat=$icon\ $(date +'%A, %d %B %R %Z')
common
}
loadavg() {
local bg=$bg_ok_trans
local fg=$text_light
local name="loadavg"
icon="󰍛"
local stat=$icon\ $(awk {'print $1,$2,$3'} /proc/loadavg)
common
}
temp_indoor() {
local bg=$bg_ok_trans
local fg=$text_light
local name="temp_indoor"
local ha_indoor=$(curl -s -H "Authorization: Bearer $ha_token" -H "Content-Type: application/json" $homeassistant_url/sensor.vindstyrka_oli_temperature | jq -r '.state')
icon=""
local stat=$icon\ $ha_indoor\ °C" "
common
}
humid_indoor() {
local bg=$bg_ok_trans
local fg=$text_light
local name="temp_indoor"
local ha_indoor=$(curl -s -H "Authorization: Bearer $ha_token" -H "Content-Type: application/json" $homeassistant_url/sensor.vindstyrka_oli_humidity | jq -r '.state')
icon=""
local stat=$icon\ $ha_indoor\ %" "
common
}
powerdraw() {
local bg=$bg_ok_trans
local fg=$text_light
local name="temp_indoor"
local ha_indoor=$(curl -s -H "Authorization: Bearer $ha_token" -H "Content-Type: application/json" $homeassistant_url/sensor.inspelning_oli_power | jq -r '.state')
icon=""
local stat=$icon\ $ha_indoor\ W" "
common
}
audio_volume() {
local name="audio"
local volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk {'print $NF*100'})
if [[ $(echo "$volume >= 50" | bc -l ) == "1" ]] && [[ $(echo "$volume < 60" | bc -l ) == "1" ]]; then
local bg=$warn1
local fg=$text_dark
elif [[ $(echo "$volume >= 60" | bc -l ) == "1" ]] && [[ $(echo "$volume < 70" | bc -l ) == "1" ]]; then
local bg=$warn2
local fg=$text_dark
elif [[ $(echo "$volume >= 70" | bc -l ) == "1" ]]; then
local bg=$crit
local fg=$text_light
else
local bg=$bg_ok_trans
local fg=$text_light
fi
icon=""
local stat=$icon\ $volume\ %" "
common
}
# header
echo '{ "version": 1 , "click_events":false}'
echo '[[],'
while :
do
echo -n "["
mydate
loadavg
temp_indoor
humid_indoor
powerdraw
temp_cpu
mem
wifi
audio_volume
echo -n "],"
sleep 5
done