Skip to content

Instantly share code, notes, and snippets.

@luis-l
Created August 9, 2018 02:20
Show Gist options
  • Save luis-l/79aa9af205d6541f4c0ef4c9c88c9f74 to your computer and use it in GitHub Desktop.
Save luis-l/79aa9af205d6541f4c0ef4c9c88c9f74 to your computer and use it in GitHub Desktop.
i3lock-color bash script and configuration
#!/bin/sh -e
# Executes i3lock-color with a configured DPMS setting.
# This is to turn off the displays much quicker when locking the system.
# Also scales the image to fit the resolution
revert()
{
xset dpms $default_sleep_time &&
rm $wallpaper
}
default_sleep_time=600
lock_sleep_time=60
wallpaper=mktemp
cp ~/Pictures/wallpaper.png $wallpaper
screenW=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1 | head -n 1)
screenH=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2 | head -n 1)
convert $wallpaper -gravity center -resize ${screenW}x${screenH}\! $wallpaper
green=00ff99c0
red=ff5050c0
cyan=66ffffa0
transparent=00000000
slighttransparent=808080e0
semitrans=80808040
timecolor=99ffdda5
timeposx=250
timeposy=$((screenH-150))
dateposy=$((timeposy+50))
timefont="Monospace"
trap revert HUP INT TERM
xset dpms $lock_sleep_time
i3lock-color \
--insidecolor=$semitrans --ringcolor=$slighttransparent --line-uses-inside \
--keyhlcolor=$green --bshlcolor=$red --separatorcolor=$transparent \
--insidevercolor=$semitrans --insidewrongcolor=$semitrans \
--ringvercolor=$cyan --ringwrongcolor=$red \
--radius=120 --ring-width=7 \
--veriftext="" --wrongtext="" --noinputtext="_" \
--wrongcolor=$red \
--clock \
--timestr="%H:%M" --timepos="x+$timeposx:y+$timeposy" --timecolor=$timecolor --time-align=2 --timesize=72 \
--time-font=$timefont \
--datestr="%a, %b %d" --datepos="x+$timeposx:y+$dateposy" --datecolor=$timecolor --date-align=2 --datesize=24 \
--date-font=$timefont \
--nofork --tiling --image $wallpaper
revert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment