diff options
author | xAlpharax <42233094+xAlpharax@users.noreply.github.com> | 2024-05-30 18:59:27 +0300 |
---|---|---|
committer | xAlpharax <42233094+xAlpharax@users.noreply.github.com> | 2024-05-30 18:59:27 +0300 |
commit | 9d5bcf2545f2c6bd2a8354c7bbcbde526b67f741 (patch) | |
tree | 067e257e3c15963a4db76557257c48560425af96 /lock | |
parent | c269e8047dd281d09533d1f676a4ac5c9715bc23 (diff) |
Auto-Lock-Screen works, tmux configured nicely and nvim configured as
well as a small change in my X11 resources and Kvantum configuration for
the Arc theme.
Changes to be committed:
modified: Kvantum/KvArcDark#/KvArcDark#.kvconfig
modified: X11/Xresources
modified: lock
modified: nvim/colors/hybrid.vim
modified: nvim/init.vim
modified: tmux/tmux.conf
Diffstat (limited to 'lock')
-rwxr-xr-x | lock | 60 |
1 files changed, 41 insertions, 19 deletions
@@ -1,6 +1,6 @@ #!/bin/bash -# This script is a workaround for xsecurelock not being able to lock the screen when a fullscreen window is active. +# This script is a workaround for xsecurelock not being able to lock the screen when a fullscreen window is in focus. # Lock the screen with xsecurelock and take care of picom lock_screen() { @@ -30,24 +30,37 @@ lock_screen() { declare -a LIST_OF_WINDOW_TITLES_THAT_PREVENT_LOCKING=( "YouTube" "Netflix" + "Disney+" + "Prime Video" + "Hulu" + "HBO Max" "Twitch" - #"Spotify" + "Spotify" + "Spotube" "MPlayer" "VLC" "mpv" + "Zoom" "Google Meet" "Microsoft Teams" - "Zoom" #"Discord" #"Slack" - #"Plex" + "Plex" + "Kodi" + "Jellyfish" + "OBS" "CCTV" ) +#for i in "${LIST_OF_WINDOW_TITLES_THAT_PREVENT_LOCKING[@]}"; do + #echo $i +#done + # Dependencies -AWK=/usr/bin/awk -GREP=/usr/bin/grep -XPROP=/usr/bin/xprop +AWK=/bin/awk +GREP=/bin/grep +XPROP=/bin/xprop +XWININFO=/bin/xwininfo # Find active window id get_active_id() { @@ -56,7 +69,7 @@ get_active_id() { # Determine a window's title text by it's ID get_window_title() { - # For mplayer or vlc, we might need to check WM_CLASS(STRING), idk. + # For some apps you may need to check WM_CLASS(STRING) instead $XPROP -id $1 | $AWK -F '=' '$1 ~ /_NET_WM_NAME\(UTF8_STRING\)/ { print $2 }' } @@ -68,32 +81,41 @@ is_fullscreen() { # Determine if the locker command should run based on which windows are fullscreened. should_lock() { + id=$(get_active_id) + if [[ $id == "" ]]; then + echo "No active window found in the workspace" + return 0 + fi + echo "$id" + title=$(get_window_title $id) + echo "Active window:$title" if is_fullscreen $id; then + echo "Fullscreen window detected:$title" + return 1 + else for i in "${LIST_OF_WINDOW_TITLES_THAT_PREVENT_LOCKING[@]}"; do if [[ $title =~ $i ]]; then - return 0 + echo "$i was found in$title" + return 1 fi done - #echo "Fullscreen window detected: $title" return 0 - else - return 1 fi } # Debugging -if should_lock; then - echo "Locking the screen..." -else - echo "Not locking the screen..." -fi +#if should_lock; then + #echo "Locking the screen..." + #/bin/dunstify -u low "Locking the screen..." +#else + #echo "Not locking the screen..." + #/bin/dunstify -u low "Not locking the screen..." +#fi # main() if should_lock; then - dunstify -u critical "Screen will close" - sleep 15 lock_screen fi |