Created
January 16, 2018 19:48
-
-
Save indeedwatson/f9a4693abadb7379c17d5695b77b6484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import os | |
import sys | |
""" Take a screenshot and save it locally | |
if -u is passed, use an external script to upload the screenshot | |
if -l is passed (default) only save locally and copy image to clipboard | |
Dependencies: | |
- maim | |
- dunst | |
- a way to upload pics, such as a script like imgur.sh or tekup | |
""" | |
# user set variables modify this to your liking: | |
# Where the pic is saved and how to set the filename | |
# by default: YYYY-MM-DD-HH-SS.png | |
pic = "$HOME/Pictures/Screenshots/$(date +%F-%H:%M).png" | |
# icon displayed by dunst | |
icon = "/usr/share/icons/Numix/32/devices/camera.svg" | |
# script or command to upload the screenshot | |
# by default it uses teknik.io because imgur compresses a lot | |
uploader = "; tekup -c " | |
def local(): | |
message = """'<b>SCREENSHOT</b> | |
Select an area to save a screenshot locally'""" | |
clipboard = " | xclip -selection clipboard -t image/png" | |
return message, clipboard | |
def upload(): | |
message = """'<b>UPLOAD</b> | |
Select an area to upload screenshot to teknik.io'""" | |
clipboard = uploader | |
return message, clipboard | |
# set local as default option if no argument is given | |
if len(sys.argv) == 1 or sys.argv[1] == "-l": | |
message, clipboard = local() | |
elif sys.argv[1] == "-u": | |
message, clipboard = upload() | |
else: | |
print(sys.argv + " is not a valid option, aborting.") | |
os.system("notify-send -t 4000 -i " + icon + " " + message) | |
os.system("maim -s " + pic + clipboard + pic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment