zeldor.biz

Linux, programming and more

Copyright © 2023
Log in

Dropbox KDE integration

November 28, 2010 by Igor Drobot Leave a Comment

After working some time with Dropbox I wrote this little python script to make my work with Dropbox more efficient and faster.

With a right click I can Upload my file to my Dropbox account:

Right Click

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python
# -*- coding:utf-8 -*-
 
import os, sys
 
PUBDIR = '/home/id/Dropbox/Public/'
USERID = 156881168
 
if len(sys.argv) > 1 and os.path.isfile(sys.argv[1]):
 os.popen('cp -f %s %s' % (sys.argv[1], PUBDIR))
 dest = 'https://dl.getdropbox.com/u/%s/%s' % (USERID, sys.argv[1].split('/')[-1])
 os.popen('kdialog --msgbox "Link was copied to the clipboard:\n%s"' % dest)
 os.system('dbus-send --print-reply --dest=org.kde.klipper \
    /klipper org.kde.klipper.klipper.setClipboardContents string:"%s"' % dest)
else:
 os.popen('kdialog --error "Please choose file!"')

#!/usr/bin/env python # -*- coding:utf-8 -*- import os, sys PUBDIR = '/home/id/Dropbox/Public/' USERID = 156881168 if len(sys.argv) > 1 and os.path.isfile(sys.argv[1]): os.popen('cp -f %s %s' % (sys.argv[1], PUBDIR)) dest = 'https://dl.getdropbox.com/u/%s/%s' % (USERID, sys.argv[1].split('/')[-1]) os.popen('kdialog --msgbox "Link was copied to the clipboard:\n%s"' % dest) os.system('dbus-send --print-reply --dest=org.kde.klipper \ /klipper org.kde.klipper.klipper.setClipboardContents string:"%s"' % dest) else: os.popen('kdialog --error "Please choose file!"')

Add a menu entry for right click:

1
2
3
4
5
6
7
8
9
10
11
12
13
vim /usr/share/kde4/services/ServiceMenus/dropbox.desktop
cat /usr/share/kde4/services/ServiceMenus/dropbox.desktop
 
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,all/allfiles
Actions=DropboxURL
X-KDE-Priority=TopLevel
 
[Desktop Action DropboxURL]
Name=Share on DropBox
Icon=/home/id/Pictures/dropbox.png
Exec=/home/id/drop_IT.py "%u" %d

vim /usr/share/kde4/services/ServiceMenus/dropbox.desktop cat /usr/share/kde4/services/ServiceMenus/dropbox.desktop [Desktop Entry] Type=Service ServiceTypes=KonqPopupMenu/Plugin,all/allfiles Actions=DropboxURL X-KDE-Priority=TopLevel [Desktop Action DropboxURL] Name=Share on DropBox Icon=/home/id/Pictures/dropbox.png Exec=/home/id/drop_IT.py "%u" %d

Update:
If you want to make it work only for special users on the system, put dropbox.desktop in your home directory: “~/.kde/share/kde4/services/ServiceMenus”

Another bash based script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
 
DROPDIR=/home/id/Dropbox/Public/
USERID=156881168
 
if [ -e "$1" ]
then
        cp -f "$1" "$DROPDIR"
        file=`basename "$1"`
        link="http://dl.getdropbox.com/u/$USERID/$file"
        notify-send -i go-down "Dropbox" "Link to \"$file\" was copied to the clipboard"
        echo "$link" | xsel -bi
else
        notify-send -i go-down "Dropbox" "Please choose file!!"
fi

#!/bin/bash DROPDIR=/home/id/Dropbox/Public/ USERID=156881168 if [ -e "$1" ] then cp -f "$1" "$DROPDIR" file=`basename "$1"` link="http://dl.getdropbox.com/u/$USERID/$file" notify-send -i go-down "Dropbox" "Link to \"$file\" was copied to the clipboard" echo "$link" | xsel -bi else notify-send -i go-down "Dropbox" "Please choose file!!" fi

Icon — Could be a pretty icon (16×16) Icon Dropbox Upload
Exec — path to you *.py script

Filed Under: Bash, Linux

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *