This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
people:glen [2014-04-08 16:19] hawk [Inner Wiki links] proper TLD name, feel free to drop this link if it bothers someone in PLD |
people:glen [2014-07-22 16:50] glen add dropbox autostart .desktop |
||
---|---|---|---|
Line 254: | Line 254: | ||
Requirements: [[https://www.dropbox.com/install?os=lnx|dropboxd]] running, [[http://ftp.gnome.org/pub/GNOME/sources/libnotify/0.7/|libnotify]], [[https://github.com/rvoicilas/inotify-tools/wiki|inotify-tools]] | Requirements: [[https://www.dropbox.com/install?os=lnx|dropboxd]] running, [[http://ftp.gnome.org/pub/GNOME/sources/libnotify/0.7/|libnotify]], [[https://github.com/rvoicilas/inotify-tools/wiki|inotify-tools]] | ||
- | You should start the script at startup of your X session. | + | You should start the script at startup of your X session, example: |
+ | <code ini ~/.config/autostart/dropbox-watch.desktop> | ||
+ | [Desktop Entry] | ||
+ | Type=Application | ||
+ | Name=Dropbox watch | ||
+ | Comment=Launch dropbox watcher script | ||
+ | Icon=dropbox | ||
+ | Exec=$HOME/.local/bin/dropbox-watch.sh | ||
+ | </code> | ||
<code bash ~/.local/bin/dropbox-watch.sh> | <code bash ~/.local/bin/dropbox-watch.sh> | ||
Line 266: | Line 274: | ||
# Author: Elan Ruusamäe <glen@delfi.ee> | # Author: Elan Ruusamäe <glen@delfi.ee> | ||
# Date: 2012-11-09 | # Date: 2012-11-09 | ||
+ | # Updated: 2014-07-22 (test all tools, more filename filters) | ||
watchdir=$HOME/Pictures/Screenshots | watchdir=$HOME/Pictures/Screenshots | ||
Line 272: | Line 281: | ||
# Config | # Config | ||
- | dropdir=$HOME/Dropbox/Public | + | dropdir=$HOME/Dropbox/Public/ss |
- | dropuser=YOUR_DROPBOX_NUMERIC_USER_ID | + | dropuser=YOUR_DROPBOX_NUMERIC_USER_ID |
- | dropurl=https://dl.dropbox.com/u/$dropuser/ss | + | dropurl=https://dl.dropboxusercontent.com/u/$dropuser/ss |
if [ ! -d $dropdir ]; then | if [ ! -d $dropdir ]; then | ||
echo >&2 "Dropbox dir $dropdir missing!" | echo >&2 "Dropbox dir $dropdir missing!" | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | if [ ! -d $watchdir ]; then | ||
+ | echo >&2 "Watch dir $watchdir missing!" | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | if ! which $viewer 2>/dev/null; then | ||
+ | echo >&2 "Can't find viewer: $viewer" | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | if ! which inotifywait 2>/dev/null; then | ||
+ | echo >&2 "Can't find tool: inotifywait, install inotify-tools" | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | if ! which notify-send 2>/dev/null; then | ||
+ | echo >&2 "Can't find tool: notify-send, install libnotify" | ||
exit 1 | exit 1 | ||
fi | fi | ||
Line 292: | Line 321: | ||
# reformat filename so it woult be nice url | # reformat filename so it woult be nice url | ||
mtime=$(stat -c "%y" "$file") | mtime=$(stat -c "%y" "$file") | ||
- | filename=$(date -d "$mtime" '+%Y-%m-%d_%H.%M.%S').png | + | # Strip 'Screenshot - 04062013 - 11:30:49 AM.png' |
+ | # strip 'Screenshot - 14.01.2013 - 15:04:02', and leave everything else part of the filename | ||
+ | fn=$(echo "$filename" | sed -e 's,^Screenshot - [ .:0-9-]*[AP]M,,') | ||
+ | # Strip 'Screenshot from 2013-02-13 23:49:07' | ||
+ | # Strip 'Screenshot - 30.05.2013 - 11:48:58.png' | ||
+ | fn=$(echo "$fn" | sed -re 's,^Screenshot( from)? [ .:0-9-]*,,') | ||
+ | |||
+ | # sanitize exts | ||
+ | fn=$(echo "$fn" | sed -re 's/\.?(jpe?g|png)$//' -e 'y/ /_/') | ||
+ | filename=$(date -d "$mtime" '+%Y-%m-%d_%H.%M.%S')${fn:+-$fn}.png | ||
+ | |||
+ | # bugfixes | ||
+ | fn=$(echo "$fn" | sed -re 's/\.png\.png$/.png/') | ||
url="$dropurl/$filename" | url="$dropurl/$filename" |