aboutsummaryrefslogtreecommitdiff
path: root/src/usr/libexec
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-09-26 21:40:46 -0400
committerB Stack <bgstack15@gmail.com>2020-09-26 21:40:46 -0400
commit5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06 (patch)
tree4ef427579548a07d78834984e5dc1110f962b0ae /src/usr/libexec
parentadd xdg autostart, and hide_when_no_media config opt (diff)
downloadmyautomount-5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06.tar.gz
myautomount-5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06.tar.bz2
myautomount-5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06.zip
add license texts, add user config to trayicon
Diffstat (limited to 'src/usr/libexec')
-rw-r--r--src/usr/libexec/myautomount/myautomount-initialize.sh1
-rwxr-xr-xsrc/usr/libexec/myautomount/myautomount-trayicon.py26
2 files changed, 17 insertions, 10 deletions
diff --git a/src/usr/libexec/myautomount/myautomount-initialize.sh b/src/usr/libexec/myautomount/myautomount-initialize.sh
index fc75d36..e415f18 100644
--- a/src/usr/libexec/myautomount/myautomount-initialize.sh
+++ b/src/usr/libexec/myautomount/myautomount-initialize.sh
@@ -1,4 +1,5 @@
#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
# Only needs to be run once. This is more for reference than for using. The package should handle these tasks.
fail() {
diff --git a/src/usr/libexec/myautomount/myautomount-trayicon.py b/src/usr/libexec/myautomount/myautomount-trayicon.py
index e326314..db20055 100755
--- a/src/usr/libexec/myautomount/myautomount-trayicon.py
+++ b/src/usr/libexec/myautomount/myautomount-trayicon.py
@@ -3,6 +3,7 @@
# License: CC-BY-SA 4.0
# Author: bgstack15
# Startdate: 2020-09-24 13:17
+# SPDX-License-Identifier: CC-BY-SA-4.0
# Title: Tray icon for automount daemon
# Purpose: Easy access to autofs-mounted removable media, without dbus
# History:
@@ -17,8 +18,6 @@
# Improve:
# move out user configs to separate file in ~/.config/myautomount, but using the xdg spec.
# add all headers
-# document
-# add option to HIDE WHEN NO MEDIA
# Dependencies:
# dep-devuan: autofs, python3-pyinotify
# dep-fedora:
@@ -32,12 +31,11 @@ from gi.repository import Gtk, Gdk, GLib
import xdg.DesktopEntry as dentry
import xdg.Exceptions as exc
-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
+showmount = os.getenv("showmount",default=1) # If 1, show the "MOUNTED" value for each drive
+skip_sd_without_partitions = os.getenv("skip_sd_without_partitions",default=1) # If 1, skip sdb sdc, etc. # NOT IMPLEMENTED YET.
+only_update_on_menuitem = os.getenv("only_update_on_menuitem",default=0) # If 1, disable the mouseover poll. Prevents showmount=1 from working.
+hide_when_no_media = os.getenv("hide_when_no_media",default=1) # If 1, stay hidden until some removable media is discovered
AUTOMOUNT_BASEDIR = os.getenv("AUTOMOUNT_BASEDIR") # probably /run/user/${UID}/automedia
if not AUTOMOUNT_BASEDIR:
print("Need env var AUTOMOUNT_BASEDIR. Aborted.",file=sys.stderr)
@@ -45,6 +43,11 @@ if not AUTOMOUNT_BASEDIR:
AUTOMOUNT_BROWSEDIR = os.getenv("AUTOMOUNT_BROWSEDIR") # probably /browse
if showmount and not AUTOMOUNT_BROWSEDIR:
print("Without AUTOMOUNT_BROWSEDIR, showmount option cannot be used. Continuing...",file=sys.stderr)
+DEBUG = os.getenv("DEBUG")
+if DEBUG:
+ print(f"hide_when no_media={hide_when_no_media}")
+ print(f"only_update_on_menuitem={only_update_on_menuitem}")
+ print(f"showmount={showmount}")
# FUNCTIONS
@@ -189,7 +192,7 @@ 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)
- if not only_update_on_menuitem:
+ if only_update_on_menuitem != 1:
self.connect("query-tooltip", self.mouseover)
# need these anyway, for when the icon is hidden.
self.wm1 = pyinotify.WatchManager()
@@ -231,13 +234,16 @@ class MainIcon(Gtk.StatusIcon):
print('{} {} {} {}'.format(entry.app.name.decode("utf-8"),entry.app.icon,entry.app.path,entry.app.command))
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:
+ if only_update_on_menuitem == 1:
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:
+ print(f"hide_when_no_media={hide_when_no_media}")
+ print(f"menuitem_count={self.menuitem_count}")
+ if str(hide_when_no_media) == "1" and self.menuitem_count == 0:
+ print("hiding self, from reestablishmenu")
self.hide()
def execute(self, widget):
bgstack15