diff options
author | Sergey Nazaryev <sergey@nazaryev.ru> | 2018-07-21 21:45:27 +0000 |
---|---|---|
committer | Sergey Nazaryev <sergey@nazaryev.ru> | 2020-08-27 19:11:57 +0300 |
commit | 4c053c05a5b61b58c74c3a3e47ef016fcde557e3 (patch) | |
tree | 7d177fe20230e66d41445c6fa726a9f79947598f /lock | |
parent | b9c05b53c284967f50a78a28c06f5991a8465640 (diff) | |
download | dotfiles-4c053c05a5b61b58c74c3a3e47ef016fcde557e3.zip dotfiles-4c053c05a5b61b58c74c3a3e47ef016fcde557e3.tar.gz dotfiles-4c053c05a5b61b58c74c3a3e47ef016fcde557e3.tar.bz2 |
Add script `.local/bin/lock` for screenlock
Diffstat (limited to 'lock')
-rwxr-xr-x | lock | 65 |
1 files changed, 65 insertions, 0 deletions
@@ -0,0 +1,65 @@ +#!/bin/sh +set -efuo pipefail + +letterEnteredColor=d23c3dff +letterRemovedColor=d23c3dff +passwordCorrect=00000000 +passwordIncorrect=d23c3dff +background=00000000 +foreground=ffffffff + +screenshot=/tmp/screenshot.jpg +thumb=/tmp/screenshot-thumb.jpg +image=/tmp/screenshot-thumb.png +i3lock_color=no +opts="-e -n" + +trap cleanup EXIT +cleanup() { + rm -f "${image}" "${screenshot}" "${thumb}" +} + +if man i3lock | /bin/grep -q i3lock-color; then + i3lock_color=yes +fi + +if command -v scrot >/dev/null 2>&1 && \ + command -v convert >/dev/null 2>&1; then + + if [ "${i3lock_color}" = 'yes' ]; then + # i3lock-color supports '*.jpg' for background + image=/tmp/screenshot-thumb.jpg + fi + + rectangles=$(xrandr --query \ + | grep ' connected' \ + | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*' \ + | sed 's/[+x]/ /g' \ + | awk '{ printf "rectangle %d %d %d %d ", $3+25, $2-30, $3+25+300, $2-30-80 }') + + scrot -t 25% "${screenshot}" + convert "${thumb}" -blur 5x2 \ + -resize 400% \ + -draw "fill rgba(0, 0, 0, 0.4) ${rectangles}" \ + "${image}" + rm -f "${screenshot}" + + opts="${opts} -i ${image}" +fi + +if [ "${i3lock_color}" = 'yes' ]; then + i3lock ${opts} \ + --timepos="x+110:h-70" \ + --datepos="x+130:h-45" \ + --clock --datestr "Type password to unlock..." \ + --insidecolor=$background --ringcolor=$foreground --line-uses-inside \ + --keyhlcolor=$letterEnteredColor --bshlcolor=$letterRemovedColor --separatorcolor=$background \ + --insidevercolor=$passwordCorrect --insidewrongcolor=$passwordIncorrect \ + --ringvercolor=$foreground --ringwrongcolor=$foreground --indpos="x+280:h-70" \ + --radius=20 --ring-width=4 --veriftext="" --wrongtext="" \ + --verifcolor="$foreground" --timecolor="$foreground" --datecolor="$foreground" \ + --noinputtext="" --time-font="SF Mono:style=Medium:size=20" \ + --force-clock +else + i3lock ${opts} -u +fi |