From 8a9b259ffcfcfb2f1406d810325491a6601e769d Mon Sep 17 00:00:00 2001 From: xAlpharax <42233094+xAlpharax@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:00:17 +0300 Subject: Massive changes that are qualitative and helpful. More modular repo. Changes to be committed: new file: Kvantum/KvArcDark#/KvArcDark#.kvconfig new file: Kvantum/kvantum.kvconfig modified: README.md modified: Vencord/settings/settings.json modified: X11/Xresources modified: X11/xinit new file: backgrounds/darkconstellation.png new file: backgrounds/dessertnight.jpg new file: backgrounds/fallingdown.png renamed: backgrounds/flower_old_tree.jpg -> backgrounds/flowertree.jpg new file: backgrounds/friend.jpg new file: backgrounds/void.png modified: bmenu modified: btop/btop.conf new file: clockpower modified: dmenu.conf new file: dunst/dunstrc modified: htop/htoprc modified: keybinds new file: lock new file: mpv/input.conf new file: mpv/mplayer-input.conf new file: mpv/mpv.conf new file: mpv/restore-old-bindings.conf new file: mpv/shaders/Anime4K_Auto_Downscale_Pre_x4.glsl new file: mpv/shaders/Anime4K_DarkLines_Fast.glsl new file: mpv/shaders/Anime4K_DarkLines_HQ.glsl new file: mpv/shaders/Anime4K_DarkLines_VeryFast.glsl new file: mpv/shaders/Anime4K_Deblur_CNN_L.glsl new file: mpv/shaders/Anime4K_Deblur_CNN_M.glsl new file: mpv/shaders/Anime4K_Deblur_DoG.glsl new file: mpv/shaders/Anime4K_Deblur_Original.glsl new file: mpv/shaders/Anime4K_Denoise_Bilateral_Mean.glsl new file: mpv/shaders/Anime4K_Denoise_Bilateral_Median.glsl new file: mpv/shaders/Anime4K_Denoise_Bilateral_Mode.glsl new file: mpv/shaders/Anime4K_RA_CNN_L.glsl new file: mpv/shaders/Anime4K_RA_CNN_M.glsl new file: mpv/shaders/Anime4K_RA_CNN_UL.glsl new file: mpv/shaders/Anime4K_RA_DoG.glsl new file: mpv/shaders/Anime4K_ThinLines_Fast.glsl new file: mpv/shaders/Anime4K_ThinLines_HQ.glsl new file: mpv/shaders/Anime4K_ThinLines_VeryFast.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_L_x2.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_L_x2_Deblur.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_L_x2_Denoise.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_M_x2.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_M_x2_Deblur.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_M_x2_Denoise.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_UL_x2.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_UL_x2_Deblur.glsl new file: mpv/shaders/Anime4K_Upscale_CNN_UL_x2_Denoise.glsl new file: mpv/shaders/Anime4K_Upscale_DTD_x2.glsl new file: mpv/shaders/Anime4K_Upscale_DoG_x2.glsl new file: mpv/shaders/Anime4K_Upscale_DoG_x2_Deblur.glsl new file: mpv/shaders/Anime4K_Upscale_Original_x2.glsl new file: mpv/shaders/Anime4K_Upscale_Original_x2_Deblur_x2.glsl new file: nbfc-kill new file: nbfc-set new file: nbfc-status modified: neofetch/config.conf modified: nvim/init.vim modified: xrec modified: xshot modified: zathura/zathurarc modified: zsh/aliases modified: zsh/env modified: zsh/zshrc --- lock | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 lock (limited to 'lock') diff --git a/lock b/lock new file mode 100755 index 0000000..bff4240 --- /dev/null +++ b/lock @@ -0,0 +1,97 @@ +#!/bin/bash + +# This script is a workaround for xsecurelock not being able to lock the screen when a fullscreen window is active. + +# Lock the screen with xsecurelock and take care of picom +lock_screen() { + # kill the compositor so that xsecurelock doesn't complain + pkill picom + + # xsecurelock configuration (you can find more flags here: https://github.com/google/xsecurelock) + + export XSECURELOCK_PASSWORD_PROMPT=time_hex + export XSECURELOCK_FONT="Inconsolata:size=17" + export XSECURELOCK_DATETIME_FORMAT=" <%H:%M>" + export XSECURELOCK_SHOW_DATETIME=1 + + export XSECURELOCK_BACKGROUND_COLOR="#0a001f" + export XSECURELOCK_AUTH_BACKGROUND_COLOR="#0a001f" + export XSECURELOCK_AUTH_FOREGROUND_COLOR="#ace6f0" + + export XSECURELOCK_DISCARD_FIRST_KEYPRESS=0 + export XSECURELOCK_BURNIN_MITIGATION=0 + + xsecurelock + + picom & +} + +# Settings +declare -a LIST_OF_WINDOW_TITLES_THAT_PREVENT_LOCKING=( + "YouTube" + "Netflix" + "Twitch" + #"Spotify" + "MPlayer" + "VLC" + "mpv" + "Google Meet" + "Microsoft Teams" + "Zoom" + #"Discord" + #"Slack" + #"Plex" + "CCTV" +) + +# Dependencies +AWK=/usr/bin/awk +GREP=/usr/bin/grep +XPROP=/usr/bin/xprop + +# Find active window id +get_active_id() { + $XPROP -root | $AWK '$1 ~ /_NET_ACTIVE_WINDOW/ { print $5 }' +} + +# 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. + $XPROP -id $1 | $AWK -F '=' '$1 ~ /_NET_WM_NAME\(UTF8_STRING\)/ { print $2 }' +} + +# Determine if a window is fullscreen based on it's ID +is_fullscreen() { + $XPROP -id $1 | $AWK -F '=' '$1 ~ /_NET_WM_STATE\(ATOM\)/ { for (i=2; i<=3; i++) if ($i ~ /FULLSCREEN/) exit 0; exit 1 }' + return $? +} + +# Determine if the locker command should run based on which windows are fullscreened. +should_lock() { + id=$(get_active_id) + title=$(get_window_title $id) + + if is_fullscreen $id; then + for i in "${LIST_OF_WINDOW_TITLES_THAT_PREVENT_LOCKING[@]}"; do + if [[ $title =~ $i ]]; then + return 0 + 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 + +# main() +if should_lock; then + lock_screen +fi -- cgit v1.2.3