From 427b77648594d1937fb58fb0844c4eec659e5182 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Thu, 2 Jun 2022 11:47:06 +0200 Subject: [PATCH] A lot of scripting --- config/sway | 32 +++++++++++++++++++++++--------- scripts/dnd.sh | 20 ++++++++++++++++++++ scripts/focus.sh | 16 ++++++++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100755 scripts/dnd.sh create mode 100755 scripts/focus.sh diff --git a/config/sway b/config/sway index 783cdc6..473bc72 100644 --- a/config/sway +++ b/config/sway @@ -28,10 +28,10 @@ seat seat0 { hide_cursor when-typing enable } -exec_always ~/.scripts/idle.sh +exec_always "~/.scripts/idle.sh" # Set warm colours at night -exec ~/.scripts/wlsunset.sh +exec "~/.scripts/wlsunset.sh" exec nm-applet --indicator exec blueman-applet @@ -51,7 +51,7 @@ set $term alacritty # bindsym F12 [title="dropdownterminal"] focus; move down 1000 # bindsym Shift+F12 [title="dropdownterminal"] move up 1000 -set $notify exec "/home/tdpeuter/.scripts/notify.sh" +set $notify exec "~/.scripts/notify.sh" # ================ # Window shortcuts @@ -232,23 +232,25 @@ bindsym $alt+Shift+space exec /usr/bin/wuzzel/wuzzel bindsym --locked XF86MonBrightnessDown exec brightnessctl -e s 5%- && $notify -b bindsym --locked XF86MonBrightnessUp exec brightnessctl -e s +5% && $notify -b -# Toggle sunset -bindsym $alt+end exec ~/.scripts/wlsunset.sh - # Media control bindsym F7 exec --no-startup-id playerctl play-pause bindsym Shift+XF86AudioLowerVolume exec --no-startup-id playerctl previous bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id playerctl next # Volume control -bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +2% && $notify -v -bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -2% && $notify -v -bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $notify -v +bindsym XF86AudioRaiseVolume exec --no-startup-id pulsemixer --change-volume +2 --max-volume 100 && $notify -v +bindsym XF86AudioLowerVolume exec --no-startup-id pulsemixer --change-volume -2 && $notify -v +bindsym XF86AudioMute exec --no-startup-id pulsemixer --toggle-mute && $notify -v bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle # Lockscreen bindsym $winkey+Delete exec --no-startup-id swaylock +# ===== +# Modes +# ===== + +# System actions set $mode_system System (l) lock, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown mode "$mode_system" { bindsym l exec --no-startup-id swaylock; mode "default" @@ -279,6 +281,18 @@ mode "$mode_screenshot" { } bindsym Print mode "$mode_screenshot" +# Some preferences +set $mode_preferences Toggle (s)unset, (n)otifications, (f)ocus +mode "$mode_preferences" { + bindsym s exec "~/.scripts/wlsunset.sh"; mode "default" + bindsym n exec "~/.scripts/dnd.sh"; mode "default" + bindsym f exec "~/.scripts/focus.sh"; mode "default" + + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $alt+end mode "$mode_preferences" + # ======= # Styling # ======= diff --git a/scripts/dnd.sh b/scripts/dnd.sh new file mode 100755 index 0000000..cc9094c --- /dev/null +++ b/scripts/dnd.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Script to toggle Do not disturb mode for mako + +# Permanent memory +saved_state=0 + +# Toggle +if [ "${saved_state}" -eq 0 ] ; then + ~/.scripts/notify.sh 'Hiding notifications' + sleep 2 + makoctl set-mode do-not-disturb +else + makoctl set-mode default + ~/.scripts/notify.sh 'Showing notifications' +fi + +# Update status in file +new_state=$( bc "(${saved_state} + 1) % 2" ) +sed -i "s/saved_state=[0|1]/saved_state=${new_state}/" ~/.scripts/dnd.sh + diff --git a/scripts/focus.sh b/scripts/focus.sh new file mode 100755 index 0000000..a239c21 --- /dev/null +++ b/scripts/focus.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Script to toggle black background to focus + +# Get instances of swaybg, except for the 'standard' one. +list=$( pgrep swaybg | head -n -1 ) + +if [ -z "${list}" ] ; then + swaybg --mode=solid_color --color=#000000 & + # Give the previous command some time to execute + sleep .1 + swaymsg reload +else + # Clean up if already running + kill $( tr ' ' '\n' <<< ${list} ) +fi +