forked from acidburn0zzz/Nemo-UltraCopier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nemo-ultracopier.py
53 lines (48 loc) · 1.77 KB
/
nemo-ultracopier.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/python
# -*- coding: utf-8 -*-
# Nemo action: Nemo-UltraCopy
# Release Date: 09 May 2014
#
# Authors: Lester Carballo Pérez(https://github.com/lestcape).
#
# Email: [email protected] Website: https://github.com/lestcape/Nemo-UltraCopy
#
# "This is an action for the Nemo browser, to paste files using ultracopier
# instead of the default nemo copier tool."
#
# This program is free software:
#
# You can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import mimetypes
import sys
import os
import urllib
from gi.repository import Gtk, Gdk
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
result = clipboard.wait_for_contents(Gdk.Atom.intern("x-special/gnome-copied-files", False))
if result is not None:
info = result.get_data().splitlines()
action = info[0]
files = info[1:]
fileList = ""
for file in files:
if file.index("file://") == 0:
fileList += " '" + urllib.unquote(file[7:]) + "'"
print fileList
print sys.argv[1]
if action == "copy":
os.system("ultracopier cp %s '%s'" % (fileList, urllib.unquote(sys.argv[1])))
elif action == "cut":
os.system("ultracopier mv %s '%s'" % (fileList, urllib.unquote(sys.argv[1])))