[sway] add base config

This commit is contained in:
Gregory Trolliet 2024-11-09 16:25:08 +01:00
parent 98db250e23
commit de2e980e62
9 changed files with 656 additions and 0 deletions

30
.config/sway/audio.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
current_volume=$(/usr/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@)
volume="$(echo $current_volume | cut -f 2 -d " " | sed 's/\.//g')"
if [[ $current_volume == *"MUTED"* ]]; then
echo "🔇"
fi
if [ "$volume" -lt "100" ]; then
volume="${volume:1}"
fi
if [ "$volume" -lt "10" ]; then
volume="${volume:1}"
fi
if [ "$volume" -gt "99" ]; then
echo "$volume%"
elif [ "$volume" -gt "65" ]; then
echo "$volume%"
elif [ "$volume" -gt "30" ]; then
echo "$volume%"
elif [ "$volume" -gt "10" ]; then
echo "$volume%"
else
echo "$volume%"
fi

312
.config/sway/config Normal file
View file

@ -0,0 +1,312 @@
#==================================================================================#
# Sway Window Manager Configuration File #
#----------------------------------------------------------------------------------#
# Purpose: This configuration file enables you to tweak keyboard shortcuts, adjust #
# themes and colors, set the wallpaper, and more. #
# #
# License: Creative Commons Attribution 4.0 International #
# Source: https://www.learnlinux.tv #
# Author:Gregory Trolliet <gregory@trolliet.info #
# #
# Pro-tip: While using Sway, you can trigger this configuration to be re-read by #
# pressing Super + Shift + C. #
#==================================================================================#
#====================================#
# Keyboard configuration #
#====================================#
input "18003:1:foostan_Corne" {
xkb_layout fr
xkb_variant ergol
}
input "1:1:AT_Translated_Set_2_keyboard" {
xkb_layout ch
xkb_variant fr
}
#========================#
# Appearance and Theming #
#========================#
# Declare Colors:
set $background #332b2b
set $color_urgent #fb4934
set $text_color #ffffff
set $title_bg_unfocused #666666
set $title_outline_active #0e844e
set $title_outline_unfocused #332b2b
# Set Colors: Border Background Text Indicator Child Border
client.background $background
client.focused $title_outline_active $background $text_color $title_outline_active $title_outline_active
client.focused_inactive $title_outline_unfocused $background $text_color $text_color $title_outline_unfocused
client.unfocused $title_outline_unfocused $title_bg_unfocused $text_color $title_outline_active
client.urgent $color_urgent $color_urgent $color_urgent $color_urgent $color_urgent
# Add gaps in between all application windows:
gaps inner 8
gaps outer 3
# Configure the default border:
default_border pixel 2
# Set the Wallpaper:
output * bg $HOME/.config/sway/wallpaper_ngnm.jpg fill
#====================================#
# Activate the panel #
#====================================#
# Set the waybar command for the application launcher:
bar {
swaybar_command waybar
}
#====================================#
# Keyboard Shortcuts (Sway-specific) #
#====================================#
# Set the modifier key to super:
set $mod Mod4
# Set the ALT key to $alt (since Mod1 is harder to remember):
set $alt Mod1
# Set up a shortcut to reload this config file:
bindsym $mod+Shift+c reload
# Quit your current session and return to the log-in manager/tty:
bindsym $mod+Shift+e exec $HOME/.config/sway/exit.sh
# Open password menu
bindsym $mod+x exec $HOME/.local/bin/passmenu --type
# Screen locking (automatic, with a timeout)
set $lock swaylock -c 550000
exec swayidle -w \
timeout 600 $lock \
timeout 570 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep $lock
# Screen locking (manual)
set $lock_screen exec bash ~/.config/sway/lock_screen.sh
bindsym $mod+Escape exec $lock_screen
#========================================#
# Keyboard Shortcuts (Window Management) #
#========================================#
# Move focus to another window:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# Move focus to another window ("cult of vim" version):
bindsym $mod+j focus down
bindsym $mod+h focus left
bindsym $mod+l focus right
bindsym $mod+k focus up
# Move the 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
# Hold the modifier key and hold the left/right mouse button
# to drag or resize a window respectively. This isn't exclusive
# to floating windows:
floating_modifier $mod normal
# Resizing containers:
mode "resize" {
# Resize windows with arrow keys:
bindsym Left resize shrink width 10px
bindsym Down resize shrink height 10px
bindsym Up resize grow height 10px
bindsym Right resize grow width 10px
# "cult of vim" version:
bindsym h resize shrink width 10px
bindsym j resize shrink height 10px
bindsym k resize grow height 10px
bindsym l resize grow width 10px
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
#========================#
# Presenter #
#========================#
mode "present" {
# command starts mirroring
bindsym m mode "default"; exec wl-present mirror
# these commands modify an already running mirroring window
bindsym o mode "default"; exec wl-present set-output
bindsym r mode "default"; exec wl-present set-region
bindsym Shift+r mode "default"; exec wl-present unset-region
bindsym s mode "default"; exec wl-present set-scaling
bindsym f mode "default"; exec wl-present toggle-freeze
bindsym c mode "default"; exec wl-present custom
# return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+p mode "present"
#=================================#
# Keyboard Shortcuts (Workspaces) #
#=================================#
# Switch to workspace
set $ws0 "0 - Presentation"
set $ws1 "1 - Hack"
set $ws2 "2 - Browsing"
set $ws3 "3 - Communication"
set $ws4 "4 - Media"
set $ws5 "5 - Writing"
set $ws6 "6 - TBD"
set $ws7 "7 - TBD"
set $ws8 "8 - TBD"
set $ws9 "9 - TBD"
# Default workspace
workspace "1 - Hack"
# Move between workspaces
bindsym $mod+0 workspace $ws0
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+0 move container to workspace $ws0
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
# Move workspace to another screen (output)
bindsym $mod+Ctrl+Left move workspace to output left
bindsym $mod+Ctrl+Right move workspace to output right
bindsym $mod+Ctrl+Up move workspace to output up
bindsym $mod+Ctrl+Down move workspace to output down
#=============================#
# Keyboard Shortcuts (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
# Toggle the current focus between tiling and floating mode
bindsym $mod+Shift+f floating toggle
# Swap focus between the tiling area and the floating area
bindsym $mod+tab focus mode_toggle
# Move focus to the parent container
bindsym $mod+a focus parent
#=================================#
# Keyboard Shortcuts (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
#===============================#
# Keyboard Shortcuts (Hardware) #
#===============================#
# Audio
bindsym XF86AudioRaiseVolume exec "wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+; pkill -RTMIN+8 waybar"
bindsym XF86AudioLowerVolume exec "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-; pkill -RTMIN+8 waybar"
bindsym XF86AudioMute exec "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle; pkill -RTMIN+8 waybar"
# Brightness
bindsym XF86MonBrightnessDown exec light -U 10
bindsym XF86MonBrightnessUp exec light -A 10
#=============================================#
# Keyboard Shortcuts (launching applications) #
#=============================================#
# Set up wofi to replace dmenu as the launcher of choice:
set $menu wofi --show drun -i | xargs swaymsg exec --
# Launch your browser:
bindsym $mod+shift+b exec firefox
# Open a file manager:
bindsym ctrl+$mod+f exec pcmanfm
# Open a terminal emulator:
set $term alacritty
bindsym $mod+t exec $term
bindsym $mod+Shift+t exec $term -e tmuxinator start default
# Kill focused window:
bindsym $mod+F4 kill
# Open the application launcher:
bindsym $mod+space exec $menu
# Open the application launcher (alternate version):
bindsym $mod+d exec $menu
#===============================#
# Default windows configuration #
#===============================#
assign [app_id="firefox"] workspace $ws2
assign [class="thunderbird-default"] workspace $ws3
for_window [class="TelegramDesktop"] resize set width 30ppt
assign [class="TelegramDesktop"] workspace $ws3
assign [class="FreeTube"] workspace $ws4
assign [app_id="at.yrlf.wl_mirror"] workspace $ws0
for_window [app_id="mpv"] resize set width 30ppt
for_window [class="Xreader"] resize set width 40ppt
for_window [app_id="org.pwmt.zathura"] resize set width 40ppt
for_window [app_id="gnome-calendar"] floating enable
#======#
# Misc #
#======#
include /etc/sway/config-vars.d/*
include /etc/sway/config.d/*

7
.config/sway/exit.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
if [[ ! $(pgrep -x "swaynag") ]]; then
swaynag --background 333333 --border 333333 --border-bottom 333333 --button-background 1F1F1F \
--button-border-size 0 --button-padding 8 --text FFFFFF --button-text FFFFFF --edge bottom \
-t warning -m 'Do you really want to log out?' -B 'You heard me!' 'swaymsg exit'
fi

17
.config/sway/light.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
brightness="$(light | sed 's/\.[0-9]*//g')"
if [ "$brightness" -gt "95" ]; then
echo "🌞"
elif [ "$brightness" -gt "75" ]; then
echo "🌕"
elif [ "$brightness" -gt "60" ]; then
echo "🌖"
elif [ "$brightness" -gt "45" ]; then
echo "🌗"
elif [ "$brightness" -gt "15" ]; then
echo "🌘"
else
echo "🌑"
fi

16
.config/sway/lock_screen.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
# Credit to the following for comming up with this:
# https://code.krister.ee/lock-screen-in-sway/
# To Do: The fancier screen lock mentioned on that page might be cool to try.
# Times the screen off and puts it to background
swayidle \
timeout 10 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' &
# Locks the screen immediately
swaylock -c 550000
# Kills last background task so idle timer doesn't keep running
kill %%