From 214b74dbde3a11978925209a435ab716f2c073a8 Mon Sep 17 00:00:00 2001 From: Felipe M Date: Tue, 29 Dec 2020 12:09:35 +0100 Subject: [PATCH] config: sway QoL --- .config/sway/config | 23 ---------- .config/sway/config.d/10-style.config | 12 ++++++ .config/sway/config.d/20-keybinds.config | 41 ++++++++++++++++++ .dotfiles/bin/lock.sh | 54 ++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 23 deletions(-) create mode 100644 .config/sway/config.d/10-style.config create mode 100644 .config/sway/config.d/20-keybinds.config create mode 100755 .dotfiles/bin/lock.sh diff --git a/.config/sway/config b/.config/sway/config index bd36903..965941a 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -166,29 +166,6 @@ output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill # Move focus to the parent container bindsym $mod+a focus parent -# -# Keybinds: -# -bindsym alt+shift+4 exec ~/.dotfiles/bin/screenshot.sh - - -# -# Gaps: -# -gaps inner 8 -smart_gaps on - -# -# Notifications: -# -bindsym ctrl+space exec makoctl dismiss -bindsym ctrl+shift+space exec makoctl dismiss --all - -# -# Window decorations: -# -default_border pixel 2 - # # Scratchpad: # diff --git a/.config/sway/config.d/10-style.config b/.config/sway/config.d/10-style.config new file mode 100644 index 0000000..848974f --- /dev/null +++ b/.config/sway/config.d/10-style.config @@ -0,0 +1,12 @@ +# +# Gaps: +# +gaps inner 8 +smart_gaps on + +# +# Window decorations: +# +default_border pixel 2 +hide_edge_borders smart + diff --git a/.config/sway/config.d/20-keybinds.config b/.config/sway/config.d/20-keybinds.config new file mode 100644 index 0000000..9a9f393 --- /dev/null +++ b/.config/sway/config.d/20-keybinds.config @@ -0,0 +1,41 @@ +set $locker ~/.dotfiles/bin/lock.sh + +# Notifications: +bindsym ctrl+space exec makoctl dismiss +bindsym ctrl+shift+space exec makoctl dismiss --all + +# Screenshot +bindsym alt+shift+4 exec ~/.dotfiles/bin/screenshot.sh + +# Multimedia Keys +# Requires: playerctl +bindsym XF86AudioRaiseVolume exec amixer -D pulse sset Master 5%+ +bindsym XF86AudioLowerVolume exec amixer -D pulse sset Master 5%- +bindsym XF86AudioMute exec amixer sset Master toggle +bindsym XF86AudioPlay exec playerctl play-pause +bindsym XF86AudioNext exec playerctl next +bindsym XF86AudioPrev exec playerctl previous + +# Screen brightness +bindsym XF86MonBrightnessUp exec brightnessctl set +5% +bindsym XF86MonBrightnessDown exec brightnessctl set 5%- + +# Lock +bindsym $mod+l exec $locker + +# Sticky windows +bindsym $mod+j sticky toggle + +# System menu +set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +mode "$mode_system" { + bindsym l exec --no-startup-id $locker, mode "default" + bindsym e exec --no-startup-id swaymsg exit, mode "default" + bindsym s exec --no-startup-id $locker && systemctl suspend, mode "default" + bindsym h exec --no-startup-id $locker && systemctl hibernate, mode "default" + bindsym r exec --no-startup-id systemctl reboot, mode "default" + bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default" + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+F12 mode "$mode_system" diff --git a/.dotfiles/bin/lock.sh b/.dotfiles/bin/lock.sh new file mode 100755 index 0000000..611abcd --- /dev/null +++ b/.dotfiles/bin/lock.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# vi: ts=4 + +# Lockscreen script that will capture a screenshot, pixelate and add an overlay (all optional). +# If no toggle is enabled, the overlay image for the final image is used instead. $overlayPath with +# a black backgrond color. +# Optional features require the `imagemagick` package. + +# Constants +lockscreenDir=$(mktemp -d) +lockscreenPath=$lockscreenDir/lock.png + +# Config +screenshotBin=grim +lockscreenBin=swaylock +overlayPath=~/.dotfiles/lock_overlay.png +font=Terminus +extraArguments= + +# Toggles +screenshot=false +pixelate=false +overlay=false + +cd $lockscreenDir + +# Take screenshot +if $screenshot; then + $screenshotBin $lockscreenPath +else + cp $HOME/.wallpaper $lockscreenPath +fi + +# Pixelate +if $pixelate; then + convert $lockscreenPath -scale 10% -scale 1000% $lockscreenPath +fi + +# Overlay +if $overlay; then + convert "$lockscreenPath" "$overlayPath" -gravity center -composite "$lockscreenPath" +fi + +if ! $screenshot && ! $pixelate && ! $overlay; then + lockscreenPath=$overlayPath + extraArguments="$extraArguments --scaling=center --color=#000001ff" +fi + +# Lock screen +$lockscreenBin \ + -n \ + --image $lockscreenPath \ + --font=$font \ + $extraArguments