add Dropbox as picture share service

--- https://www.pld-linux.org/people/glen?rev=1351499116
+++ https://www.pld-linux.org/people/glen
@@ -248,5 +248,65 @@
  
  
  <file>poldek --sn carme --up -u $(rpm -qa --qf '%{N} %{V}-%{R}\n' | awk 
-vv=$(rpm -q php-common --qf '%{V}-%{R}') '$2 == v {sub(/php/, "php54", $1); 
print $1}')
  </file>
+ 
+ ===== Dropbox as picture share service =====
+ 
+ Any file saved to ''~/Pictures/Screenshots'' gets renamed based on timestamp 
and moved to ''~/Dropbox/Public'' folder.
+ 
+ When the move is done, URL for the image is copied to clipboard and image 
viewer is opened so you can see your image before you paste the url to IM, 
e-mail, etc...
+ 
+ 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.
+ 
+ <code bash ~/.local/bin/dropbox-watch.sh>
+ #!/bin/sh
+ # A script that watches ~/Pictures/Screenshots dir, and any new file is added 
there, it
+ # is renamed so it would contain filename modify timestamp (uses safe
+ # characters not to require urlencode) and moved to dropbox dir. Additionally
+ # dropbox url is copied to clipboard and image viewer is opened to show that
+ # screenshot.
+ #
+ # Author: Elan Ruusamäe <[email protected]>
+ # Date: 2012-11-09
+ 
+ watchdir=$HOME/Pictures/Screenshots
+ # i'd use xdg-open here, but somewhy in GNOME 3.4 it opens dir containing the 
image
+ viewer=gpicview
+ 
+ # Config
+ dropdir=$HOME/Dropbox/Public
+ dropuser=YOUR_DROPBOX_NUMERIC_USER_ID
+ dropurl=https://dl.dropbox.com/u/$dropuser/ss
+ 
+ if [ ! -d $dropdir ]; then
+       echo >&2 "Dropbox dir $dropdir missing!"
+       exit 1
+ fi
+ 
+ inotifywait -m -e moved_to -e close_write $watchdir | while read path change 
filename; do
+       case "$change" in
+       CREATE|MOVED_TO|*CLOSE_WRITE*)
+               file=$path/$filename
+               ;;
+       *)
+               continue
+       esac
+ 
+       # reformat filename so it woult be nice url
+       mtime=$(stat -c "%y" "$file")
+       filename=$(date -d "$mtime" '+%Y-%m-%d_%H.%M.%S').png
+ 
+       url="$dropurl/$filename"
+ 
+       mv "$file" "$dropdir/$filename"
+ 
+       $viewer "$dropdir/$filename" &
+ 
+       # Copy URL to clipboard and notify the user
+       echo -n "$url" | xclip -selection c
+       notify-send --hint=int:transient:1 "Screenshot Uploaded" "Copied URL to 
clipboard:\n$url"
+ done
+ </code>
  


Diff URL:
  https://www.pld-linux.org/people/glen?do=diff&r1=1351499116&r2=1355997628
-- 
This mail was generated by DokuWiki at
https://www.pld-linux.org/
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to