Skip to content

Instantly share code, notes, and snippets.

@Dobbie03
Created February 4, 2018 01:42
Show Gist options
  • Select an option

  • Save Dobbie03/e1b54d2e6815c39be0fbae6494a441bd to your computer and use it in GitHub Desktop.

Select an option

Save Dobbie03/e1b54d2e6815c39be0fbae6494a441bd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Take a screenshot and display a notification.
#
# Created by Dylan Araps.
#
# Depends on: imagemagick, libnotify (patched with id support)
# Screenshot directory
scr_dir="${HOME}/Screenshots/ArchLabs"
mkdir -p "$scr_dir" || { printf "%s\n" "Error: Couldn't create screenshot directory"; exit; }
# Use printf to store the current date/time as variables.
printf -v date "%(%F)T"
printf -v time "%(%I-%M-%S)T"
# Create current date format.
mkdir -p "${scr_dir}/${date}"
# Name the screenshot
scr="${scr_dir}/${date}/${date}-${time}.png"
notify-send " Saved screenshot as ${scr/*\/}"
scrot "$scr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment