scripts

Utility script that make my life slightly easier
Log | Files | Refs | README | LICENSE

lockimg.sh (1524B)


      1 #!/bin/sh
      2 
      3 #lock image selector
      4 #"lockimg.sh"
      5 #M. Yamanaka
      6 #email: myamanaka@live.com
      7 #website: csmyamanaka.com
      8 #license: MIT (See included "LICENSE" file for details)
      9 
     10 ##
     11 ## Description
     12 ##
     13 ## This is a wrapper script for i3lock that selects an image to be used as the background
     14 
     15 ## This assumes you have archlinux with the package "archlinux-wallpaper" installed
     16 ## If not, the variable WPDIR (wallpaper directory)can just be changed to something else
     17 
     18 WPDIR=/usr/share/backgrounds/archlinux
     19 
     20 ## i3lock, to my knowledge, does not automatically resize the image to fit with your screen
     21 ## so it's necessary to do some work on these images if you want a nice lock screen that
     22 ## isn't cropped weirdly or anything like that.
     23 
     24 ## imagemagick's resize accepts screen resolutions in the format 1200x800
     25 
     26 SCRSIZE=$(xrandr | grep "current" | awk '{print $8"x"$10}' | sed s/,//g)
     27 
     28 ## Because the files in WPDIR are owned by root, you won't be able to overwrite them so
     29 ## you need to set a destination file. This assumes you have .local/tmp but this can be
     30 ## wherever you want
     31 
     32 LOCKIMG=$HOME/.local/tmp/lockimg.png
     33 
     34 ## I like to choose randomly from the .png images in the arch wallpaper directories
     35 ## for lock screen images. I tend to use the .jpg files for desktop wallpapers
     36 
     37 ORIGIMG=$(ls $WPDIR/*.png | shuf -n 1)
     38 
     39 ## You can use imagemagick to make a resized copy of the wallpaper to $LOCKIMG
     40 
     41 convert $ORIGIMG -resize $SCRSIZE\! $LOCKIMG
     42 
     43 ## now use i3lock or whatever screen locking program you choose
     44 
     45 i3lock -i $LOCKIMG

Generated using stagit (https://codemadness.org/stagit.html)