-
Notifications
You must be signed in to change notification settings - Fork 0
/
open-folder-VLC.py
51 lines (39 loc) · 1.22 KB
/
open-folder-VLC.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
import gi
import shutil
import subprocess
gi.require_version('Nautilus', '4.0')
from gi.repository import Nautilus, GObject
from typing import List
class openFolderVLC(GObject.GObject, Nautilus.MenuProvider):
def __init__(self):
super().__init__()
def menu_activate_cb(
self,
menu: Nautilus.MenuItem,
file: Nautilus.FileInfo,
) -> None:
if file.is_gone():
return
subprocess.Popen(["cvlc",file.get_uri()],stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT,start_new_session=True)
def get_file_items(
self,
files: List[Nautilus.FileInfo],
) -> List[Nautilus.MenuItem]:
if len(files) != 1 or shutil.which("cvlc") is None:
return []
file = files[0]
if not file.is_directory():
return[]
item = Nautilus.MenuItem(
name="abrirConVLC",
label="Abrir con VLC: %s" % file.get_name(),
)
item.connect("activate", self.menu_activate_cb, file)
return [
item,
]
def get_background_items(
self,
current_folder: Nautilus.FileInfo,
) -> List[Nautilus.MenuItem]:
return []