[
  {
    "path": "README.md",
    "content": "```\n ┏━┓┳  o┏┓┓┏━┓┳ ┳┳  ┏━┓┏━┓┳┏ \n ┃ ┳┃  ┃ ┃ ┃  ┃━┫┃  ┃ ┃┃  ┣┻┓\n ┇━┛┇━┛┇ ┇ ┗━┛┇ ┻┇━┛┛━┛┗━┛┇ ┛\n\n```\n\nglitchlock: a glitch art themed randomized lockscreen. powered by i3lock-color.\n\n![glitchlock preview](https://raw.githubusercontent.com/xero/glitchlock/master/preview.png)\n\n(note, the lock screen is **NOT** animated. this gif is meant to showcase it's random output)\n\n## table of contents\n* [about](#about)\n* [how it works](#how-it-works)\n* [security](#security)\n* [requirements](#requirements)\n* [customize](#customize)\n* [more](#more)\n* [license](#license)\n\n### about\n\ni do [glitch art](https://lab.x-e.ro/glitches) for fun. i was messing around w/ one of my shell scripts and thought: this would make a cool lockscreen! after a bit of research and refactoring here we are.\n\n### how it works\n\nthe script takes a screenshot, corrupts it, then optionally overlays an image (one for each display) then uses that image as the background for the lockscreen.\n\n### security\n\nthis lockscreen has the potential for information leakage, since it uses a screenshot of your active screen. i made this for fun and personal use, please take care and weigh your opsec and personal threat model before deciding to use this.\n\nan example workaround would be setting up your screen very nicely w/o any secret info in it and taking a screenshot. then replace [line #9](https://github.com/xero/glitchlock/blob/master/glitchlock#L9) in the script (`scrot /tmp/lock.png`) with a command to {move,copy} your pre-setup screenshot into place (e.g. `cp ~/lib/img/lock.png /tmp/lock.png`) then let the script randomly glitch that image out everytime.\n\n### requirements\n\n* i3lock-color\n\t* the \"ricing\" fork of the lockscreen application\n\t* https://github.com/PandorasFox/i3lock-color\n* scrot\n\t* the premiere nix screen shot tool\n\t* https://github.com/dreamer/scrot\n* imagemagick\n\t* image manipulation toolkit\n\t* https://github.com/ImageMagick/ImageMagick\n\nif you're using [arch](https://www.archlinux.org) they can all be installed from the extra, community, and aur repos:\n\n`yay -S i3lock-color-git scrot imagemagick`\n\n\\* [yay](https://github.com/Jguer/yay) is an aur helper that wraps [pacman](https://www.archlinux.org/pacman/).\n\n### customize\n\nif called alone, the script will take a screenshot and glitch it. but you can optionally pass an environment variable named  `GLITCHICON` to the app and it will center that image on each display and overlay it on the glitched image.\n\nan example of calling the script on `MOD4+ESC` using [sxhkd](https://github.com/baskerville/sxhkd)\n\n```\n# lockscreen\nmod4 + Escape\n GLITCHICON=~/src/glitchlock/stop.png ~/bin/glitchlock\n```\n\n### more\n\n* https://0w.nz\n* https://x-e.ro\n* https://nixers.net\n* https://git.io/.files\n* https://reddit.com/r/unixporn\n\n## license\n\n![kopimi logo](https://gist.githubusercontent.com/xero/cbcd5c38b695004c848b73e5c1c0c779/raw/6b32899b0af238b17383d7a878a69a076139e72d/kopimi-sm.png)\n\n[kopimi](https://kopimi.com)! in the spirit of _freedom of information_, i encourage you to fork, modify, change, share, or do whatever you like with this project! `^c^v`\n"
  },
  {
    "path": "glitchlock",
    "content": "#!/bin/bash\n# ┏━┓┳  o┏┓┓┏━┓┳ ┳┳  ┏━┓┏━┓┳┏ \n# ┃ ┳┃  ┃ ┃ ┃  ┃━┫┃  ┃ ┃┃  ┣┻┓\n# ┇━┛┇━┛┇ ┇ ┗━┛┇ ┻┇━┛┛━┛┗━┛┇ ┛\n#\n# author: xero <x@xero.nu> http://xero.nu\n# requires: i3lock-color, imagemagick, scrot\n\nscrot /tmp/lock.png\nmagick /tmp/lock.png /tmp/lock.jpg\nfile=/tmp/lock.jpg\n\nfunction datamosh() {\n\tfileSize=$(wc -c < \"$file\")\n\theaderSize=1000\n\tskip=$(shuf -i \"$headerSize\"-\"$fileSize\" -n 1)\n\tcount=$(shuf -i 1-10 -n 1)\n\tfor i in $(seq 1 $count);do byteStr=$byteStr'\\x'$(shuf -i 0-255 -n 1); done;   \n\tprintf $byteStr | dd of=\"$file\" bs=1 seek=$skip count=$count conv=notrunc >/dev/null 2>&1\n}\n\nsteps=$(shuf -i 40-70 -n 1)\nfor i in $(seq 1 $steps);do datamosh \"$file\"; done\n\nGLITCHICON=${GLITCHICON:=\"\"}\nPARAM=(--bar-indicator --bar-orientation horizontal --bar-direction 1 --redraw-thread -t \"\" \\\n\t--bar-step 50 --bar-total-width 250 --bar-base-width 50 --bar-max-height 100 --bar-periodic-step 50 \\\n\t--bar-color 00000077 --keyhl-color 00666666 --ringver-color cc87875f --wrong-color ffff0000 \\\n\t--verif-text=\"\" --wrong-text=\"\" --noinput-text=\"\" )\n\nLOCK=()\nwhile read LINE\ndo\n\tif [[ \"$LINE\" =~ ([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+) ]]; then\n\t\tW=${BASH_REMATCH[1]}\n\t\tH=${BASH_REMATCH[2]}\n\t\tXoff=${BASH_REMATCH[3]}\n\t\tYoff=${BASH_REMATCH[4]}\n\t\tif [ ! -z \"$GLITCHICON\" ]; then\n\t\t\tIW=`identify -ping -format '%w' $GLITCHICON`\n\t\t\tIH=`identify -ping -format '%h' $GLITCHICON`\n\t\t\tMIDXi=$(($W / 2 + $Xoff - $IW / 2))\n\t\t\tMIDYi=$(($H / 2 + $Yoff - $IH / 2))\n\t\t\tLOCK+=($GLITCHICON -geometry +$MIDXi+$MIDYi -composite)\n\t\tfi\n\tfi\ndone <<<\"$(xrandr)\"\n\nmagick /tmp/lock.jpg /tmp/lock.png >/dev/null 2>&1\nrm /tmp/lock.jpg\nfile=/tmp/lock.png\n\nmagick \"$file\" \"${LOCK[@]}\" \"$file\"\n\ni3lock -n \"${PARAM[@]}\" -i \"$file\" > /dev/null 2>&1\n"
  }
]