diff options
author | B Stack <bgstack15@gmail.com> | 2020-09-26 21:40:46 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-09-26 21:40:46 -0400 |
commit | 5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06 (patch) | |
tree | 4ef427579548a07d78834984e5dc1110f962b0ae /src | |
parent | add xdg autostart, and hide_when_no_media config opt (diff) | |
download | myautomount-5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06.tar.gz myautomount-5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06.tar.bz2 myautomount-5c3a8832ee7e4cd4c613d2af947ddfff9aac8d06.zip |
add license texts, add user config to trayicon
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/myautomount.conf | 6 | ||||
-rwxr-xr-x | src/usr/bin/myautomount-trayicon | 2 | ||||
-rwxr-xr-x | src/usr/bin/myautomountd | 1 | ||||
-rw-r--r-- | src/usr/libexec/myautomount/myautomount-initialize.sh | 1 | ||||
-rwxr-xr-x | src/usr/libexec/myautomount/myautomount-trayicon.py | 26 | ||||
-rw-r--r-- | src/usr/share/doc/myautomount/myautomount.conf.example | 5 |
6 files changed, 31 insertions, 10 deletions
diff --git a/src/etc/myautomount.conf b/src/etc/myautomount.conf index eef2ca8..a64dace 100644 --- a/src/etc/myautomount.conf +++ b/src/etc/myautomount.conf @@ -19,3 +19,9 @@ export AUTOMOUNT_BASEDIR=/run/user/${UID}/automedia # where the filesystems get mounted to. This location should not be # controlled by anything else. export AUTOMOUNT_BROWSEDIR=/browse + +# These can be modified per-user in ${XDG_CONFIG_HOME}/myautomount.conf +export showmount=1 # Default: 1, show "MOUNTED" for each drive that is currently mounted +export skip_sd_without_partitions=1 # Default: 1, skip sdb sdc, etc. # NOT IMPLEMENTED YET +export only_update_on_menuitem=0 # Default: 0, disable the mouseover poll. If 1, it breaks showmount=1 +export hide_when_no_media=1 # Default: 1, stay hidden until some removable media is discovered diff --git a/src/usr/bin/myautomount-trayicon b/src/usr/bin/myautomount-trayicon index 08be25d..2b39ced 100755 --- a/src/usr/bin/myautomount-trayicon +++ b/src/usr/bin/myautomount-trayicon @@ -1,4 +1,6 @@ #!/bin/sh # Part of myautomount project . ${MYA_PREFIX}/etc/myautomount.conf +. ${XDG_CONFIG_HOME:-${HOME}/.config}/myautomount.conf +env ${MYA_PREFIX}/usr/libexec/myautomount/myautomount-trayicon.py diff --git a/src/usr/bin/myautomountd b/src/usr/bin/myautomountd index 3501b97..a5d8828 100755 --- a/src/usr/bin/myautomountd +++ b/src/usr/bin/myautomountd @@ -3,6 +3,7 @@ # Location: gitlab # Authors: beanpole135, bgstack15 # Startdate: 2020-09-23 +# SPDX-License-Identifier: CC-BY-SA-4.0 # Title: Automount in Shell # Purpose: # History: 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): diff --git a/src/usr/share/doc/myautomount/myautomount.conf.example b/src/usr/share/doc/myautomount/myautomount.conf.example new file mode 100644 index 0000000..6cb3ac4 --- /dev/null +++ b/src/usr/share/doc/myautomount/myautomount.conf.example @@ -0,0 +1,5 @@ +# This config file can be placed at ~/.config/myautomount.conf and will override /etc/myautomount.conf. +export showmount=1 # Default: 1, show "MOUNTED" for each drive that is currently mounted +export skip_sd_without_partitions=1 # Default: 1, skip sdb sdc, etc. # NOT IMPLEMENTED YET +export only_update_on_menuitem=0 # Default: 0, disable the mouseover poll. If 1, it breaks showmount=1 +export hide_when_no_media=1 # Default: 1, stay hidden until some removable media is discovered |