From fa09281b4835be0b8c56030581de98035a6afd4a Mon Sep 17 00:00:00 2001 From: spinach <19keegandeppe@gmail.com> Date: Sun, 29 Jan 2023 20:27:46 -0500 Subject: [PATCH] initial scripts --- i3lock-fancy-dualmonitor | 100 +++++++++++++++++++++++++++++++++++++++ lock.png | Bin 0 -> 2551 bytes lock.sh | 8 ++++ res | 26 ++++++++++ 4 files changed, 134 insertions(+) create mode 100755 i3lock-fancy-dualmonitor create mode 100644 lock.png create mode 100755 lock.sh create mode 100755 res diff --git a/i3lock-fancy-dualmonitor b/i3lock-fancy-dualmonitor new file mode 100755 index 0000000..f28e58e --- /dev/null +++ b/i3lock-fancy-dualmonitor @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# Author: Dolores Portalatin +# Dependencies: imagemagick, i3lock-color-git, scrot +set -o errexit -o noclobber -o nounset + +HUE=(-level 0%,100%,0.6) +EFFECT=(-filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500.5%) +# default system sans-serif font +FONT="$(convert -list font | awk "{ a[NR] = \$2 } /family: $(fc-match sans -f "%{family}\n")/ { print a[NR-1]; exit }")" +#IMAGE="$(mktemp).png" +IMAGE=$(mktemp --suffix=.png) +SHOT=(import -silent -window root) +DM=$(xdpyinfo | awk '/^ dimensions(.+([0-9]+))/{print $2}') + +OPTIONS="Options: + -h, --help This help menu. + -g, --greyscale Set background to greyscale instead of color. + -p, --pixelate Pixelate the background instead of blur, runs faster. + -f , --font Set a custom font. Type 'convert -list font' in a terminal to get a list." + +# move pipefail down as for some reason "convert -list font" returns 1 +set -o pipefail +trap 'rm -f "$IMAGE"' EXIT +TEMP="$(getopt -o :hpgf: -l help,pixelate,greyscale,font: --name "$0" -- "$@")" +eval set -- "$TEMP" + +while true ; do + case "$1" in + -h|--help) + printf "Usage: $(basename $0) [options]\n\n$OPTIONS\n\n" ; exit 1 ;; + -g|--greyscale) HUE=(-level 0%,100%,0.6 -set colorspace Gray -separate -average) ; shift ;; + -p|--pixelate) EFFECT=(-scale 10% -scale 1000%) ; shift ;; + -f|--font) + case "$2" in + "") shift 2 ;; + *) FONT=$2 ; shift 2 ;; + esac ;; + --) shift ; break ;; + *) echo "error" ; exit 1 ;; + esac +done + +# l10n support +TEXT="Type password to unlock" +case "${LANG:-}" in + de_* ) TEXT="Bitte Passwort eingeben" ;; # Deutsch + da_* ) TEXT="Indtast adgangskode" ;; # Danish + en_* ) TEXT="Type password to unlock" ;; # English + es_* ) TEXT="Ingrese su contraseña" ;; # Española + fr_* ) TEXT="Entrez votre mot de passe" ;; # Français + he_* ) TEXT="הליענה לטבל המסיס דלקה" ;; # Hebrew עברית (convert doesn't play bidi well) + id_* ) TEXT="Masukkan kata sandi Anda" ;; # Bahasa Indonesia + it_* ) TEXT="Inserisci la password" ;; # Italian + ja_* ) TEXT="パスワードを入力してください" ;; # Japanese + lv_* ) TEXT="Ievadi paroli" ;; # Latvian + pl_* ) TEXT="Podaj hasło" ;; # Polish + pt_* ) TEXT="Digite a senha para desbloquear" ;; # Português + ru_* ) TEXT="Введите пароль" ;; # Russian + * ) TEXT="Type password to unlock" ;; # Default to English +esac + +#scrot -z "$IMAGE" +command -- "${SHOT[@]}" "$IMAGE" + +ICON="/usr/share/i3lock-fancy-dualmonitor/lock.png" +PARAM=("--insidecolor=0000001c" "--ringcolor=0000003e" \ + "--linecolor=00000000" "--keyhlcolor=ffffff80" "--ringvercolor=ffffff00" \ + "--separatorcolor=22222260" "--insidevercolor=ffffff1c" \ + "--ringwrongcolor=ffffff55" "--insidewrongcolor=ffffff1c" \ + "--verifcolor=ffffff00" "--wrongcolor=ff000000" "--timecolor=ffffff00" \ + "--datecolor=ffffff00" "--layoutcolor=ffffff00") + +LOCK=() +while read LINE +do + if [[ "$LINE" =~ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) ]]; then + W=${BASH_REMATCH[1]} + H=${BASH_REMATCH[2]} + Xoff=${BASH_REMATCH[3]} + Yoff=${BASH_REMATCH[4]} + MIDXi=$(($W / 2 + $Xoff - 60 / 2)) + MIDYi=$(($H / 2 + $Yoff - 60 / 2)) + MIDXt=$(($W / 2 + $Xoff - 285 / 2)) + MIDYt=$(($H / 2 + $Yoff + 320 / 2)) + MIDXts=$(($MIDXt + 2)) + MIDYts=$(($MIDYt + 2)) + LOCK+=(\( -size $DM xc:none -font $FONT -pointsize 26 -fill black -annotate +$MIDXts+$MIDYts "$TEXT" -blur 0x2 \ + -fill black -annotate +$MIDXts+$MIDYts "$TEXT" -blur 0x1 -fill white -annotate +$MIDXt+$MIDYt "$TEXT" \) \ + -flatten \ + $ICON -geometry +$MIDXi+$MIDYi -composite) + fi +done <<<"$(xrandr)" + +convert "$IMAGE" "${HUE[@]}" "${EFFECT[@]}" "${LOCK[@]}" "$IMAGE" + +# try to use a forked version of i3lock with prepared parameters +if ! i3lock -n "${PARAM[@]}" -i "$IMAGE" > /dev/null 2>&1; then + # We have failed, lets get back to stock one + i3lock -n -i "$IMAGE" +fi diff --git a/lock.png b/lock.png new file mode 100644 index 0000000000000000000000000000000000000000..d203a08c14e54a0a84666f350010f88c98b8ddc9 GIT binary patch literal 2551 zcmVmH@`!F-au^q>DY?NL;>By2jGv|E%{`3Fm{O2Fw2L|$-`k+~jI86bNd0JHmQ?2JR z02*U#Z739K35Ub2O-)TdZ)41m$l(9pbl_wL_zbaWhOZf@Sv*w|P{2q8)>=0J!&gm^rj9335< zxOC~#mpwf_{}>w^yQ!2)0N|(~@k$bA06c!bzv1Z@M2q1+DDP9S}1b{{e@rA?T-6u|*cxUh4y}uGd zKnU@SsEcgEz=FyEKq&=d42&@h4-ZcqKYskZ8#iwJQwT8)+tgP?nyut!ERcO+=gysP ze){RBe`{-N3tN^2&N;G`%|{l%qTiKL&;F=}hK9NW2M)ZRNF@9>Z{GY$DV4?wo!UwW z6977Z!2bRF|9s}mnRnK$TNkh_3qpt-RS6-_K8t};3Q|fKhN11*vuC@eX^q#eUAqQg zMWk0kSO-wMef##`fB4~te+>izwU%Y&DC!coEKAba!|Eee>qc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@ +#!/bin/bash +TMPBG=/tmp/screen.png +LOCK=$HOME/lock.png +RES=$(xrandr | grep 'current' | sed -E 's/.*current\s([0-9]+)\sx\s([0-9]+).*/\1x\2/') + +ffmpeg -f x11grab -video_size $RES -y -i $DISPLAY -i $LOCK -filter_complex "boxblur=5:1,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -vframes 1 $TMPBG -loglevel quiet +i3lock -i $TMPBG +rm $TMPBG diff --git a/res b/res new file mode 100755 index 0000000..a318395 --- /dev/null +++ b/res @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +SR="$(xrandr -q | grep ' connected ' | grep -o '[0-9]*x[0-9]*+[0-9]*+[0-9]*')" + +for RES in $SR; do + W="$(awk -F '[x+]' '{print $1}' <<< "$RES")" + H="$(awk -F '[x+]' '{print $2}' <<< "$RES")" + Xoff="$(awk -F '[x+]' '{print $3}' <<< "$RES")" + Yoff="$(awk -F '[x+]' '{print $4}' <<< "$RES")" + MIDX=$(($W / 2 + $Xoff - 60 / 2)) + MIDY=$(($H / 2 + $Yoff - 60 / 2)) + printf "X: $W\nY: $H\nX-offset: $Xoff\nY-offset: $Yoff\nmiddlex: $MIDX\nmiddley: $MIDY\n" +done + +while read LINE +do + if [[ "$LINE" =~ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) ]]; then + W=${BASH_REMATCH[1]} + H=${BASH_REMATCH[2]} + Xoff=${BASH_REMATCH[3]} + Yoff=${BASH_REMATCH[4]} + MIDX=$(($W / 2 + $Xoff - 60 / 2)) + MIDY=$(($H / 2 + $Yoff - 60 / 2)) + printf "X: $W\nY: $H\nX-offset: $Xoff\nY-offset: $Yoff\nmiddlex: $MIDX\nmiddley: $MIDY\n" + fi +done <<<"$(xrandr)"