aboutsummaryrefslogtreecommitdiff
path: root/src/usr/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/libexec')
-rwxr-xr-xsrc/usr/libexec/myautomount/myautomount-trayicon.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/usr/libexec/myautomount/myautomount-trayicon.py b/src/usr/libexec/myautomount/myautomount-trayicon.py
index 257c54f..e326314 100755
--- a/src/usr/libexec/myautomount/myautomount-trayicon.py
+++ b/src/usr/libexec/myautomount/myautomount-trayicon.py
@@ -4,7 +4,7 @@
# Author: bgstack15
# Startdate: 2020-09-24 13:17
# Title: Tray icon for automount daemon
-# Purpose: Easy access to autofs-mounted removable media
+# Purpose: Easy access to autofs-mounted removable media, without dbus
# History:
# Usage:
# to be called from /usr/bin/myautomount-trayicon only, because it loads the environment variables
@@ -32,9 +32,10 @@ from gi.repository import Gtk, Gdk, GLib
import xdg.DesktopEntry as dentry
import xdg.Exceptions as exc
-showmount = 1 # show the "MOUNTED" value for each drive
-skip_sd_without_partitions = 1 # skip sdb sdc, etc. # NOT IMPLEMENTED YET.
-only_update_on_menuitem = 0 # if 1, then disables the mouseover poll. Prevents showmount=1 from working.
+showmount = 1 # Default: 1, show the "MOUNTED" value for each drive
+skip_sd_without_partitions = 1 # Default: 1, skip sdb sdc, etc. # NOT IMPLEMENTED YET.
+only_update_on_menuitem = 0 # Default: 0, disable the mouseover poll. Prevents showmount=1 from working.
+hide_when_no_media = 1 # Default: 1, stay hidden until some removable media is discovered
# load environment variables
AUTOMOUNT_BASEDIR = os.getenv("AUTOMOUNT_BASEDIR") # probably /run/user/${UID}/automedia
@@ -188,7 +189,6 @@ class MainIcon(Gtk.StatusIcon):
self.traymenu = Gtk.Menu()
self.connect("button-press-event", self.on_button_press_event)
self.connect("popup-menu", self.context_menu)
- self.reestablish_menu()
if not only_update_on_menuitem:
self.connect("query-tooltip", self.mouseover)
# need these anyway, for when the icon is hidden.
@@ -199,6 +199,7 @@ class MainIcon(Gtk.StatusIcon):
self.notifier1 = pyinotify.ThreadedNotifier(self.wm1, default_proc_fun=self.identity)
self.notifier1.start()
self.wm1.add_watch(AUTOMOUNT_BASEDIR, pyinotify.IN_CREATE | pyinotify.IN_DELETE, rec=True, auto_add=True)
+ self.reestablish_menu()
def mouseover(self, second_self, x, y, some_bool, tooltip):
#print("Mouseover happened at",str(x)+",",y,tooltip, some_bool)
@@ -231,11 +232,13 @@ class MainIcon(Gtk.StatusIcon):
self.add_menuitem(str(entry.app.name.decode("utf-8")),entry.app.path,entry.app.icon,self.execute,entry.app.command)
self.add_separator_to_menu()
if only_update_on_menuitem:
- self.add_menuitem("Update menu","",None,self.reestablish_menu,"re establish") # If you want a menu option for this
- self.add_menuitem("Hide until next disk change","","",self.hide,"hide")
- self.add_menuitem("Exit automount-trayicon","","system-logout",self.exit,"exit")
- self.menuitem_count = len(self.menuitems) - 2
+ self.add_menuitem("Update menu","",None,self.reestablish_menu,"FALSE")
+ self.add_menuitem("Hide until next disk change","","",self.hide,"FALSE")
+ self.add_menuitem("Exit automount-trayicon","","system-logout",self.exit,"FALSE")
+ self.menuitem_count = len(self.menuitems)
self.set_tooltip_text(str(self.menuitem_count)+" mount point"+("s" if self.menuitem_count > 1 else ""))
+ if hide_when_no_media and self.menuitem_count == 0:
+ self.hide()
def execute(self, widget):
x=0 ; y=-1
@@ -259,7 +262,9 @@ class MainIcon(Gtk.StatusIcon):
self.traymenu.append(i)
def add_menuitem(self,label_str,label_paren_str,icon_str,function_func,action_str):
- self.menuitems.append(action_str)
+ # only count the real items
+ if action_str != "FALSE":
+ self.menuitems.append(action_str)
full_label_str=label_str
mounted_str=""
# collection = [line.split()[1] for line in open("/etc/mtab") if line.split()[1].startswith('/browse') and line.split()[2] != "autofs"]
bgstack15