aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-03-20 23:31:47 +0000
committerB Stack <bgstack15@gmail.com>2020-03-20 23:31:47 +0000
commitde27241bd617ac3a37fdd1511d173743704e615e (patch)
tree4521e58dbb6f7a057dd5fde71b4230b115b8b326
parentMerge branch 'add-ncurses' into 'master' (diff)
parentmove debian/ to stackrpms (diff)
downloadlogout-manager-de27241bd617ac3a37fdd1511d173743704e615e.tar.gz
logout-manager-de27241bd617ac3a37fdd1511d173743704e615e.tar.bz2
logout-manager-de27241bd617ac3a37fdd1511d173743704e615e.zip
Merge branch 'add-trayicon' into 'master'
release 0.0.2 Closes #1 See merge request bgstack15/logout-manager!2
-rw-r--r--README.md3
-rwxr-xr-xalt/logout-manager-trayicon.sh83
-rw-r--r--debian/README.Debian5
-rw-r--r--debian/changelog5
-rw-r--r--debian/compat1
-rw-r--r--debian/control17
-rw-r--r--debian/copyright29
-rw-r--r--debian/do-not-install1
-rw-r--r--debian/logout-manager.conffiles2
-rw-r--r--debian/logout-manager.dsc14
-rw-r--r--debian/logout-manager.install0
-rw-r--r--debian/logout-manager.lintian-overrides4
-rw-r--r--debian/logout-manager.postinst9
-rw-r--r--debian/logout-manager.prerm11
-rw-r--r--debian/patches/series1
-rwxr-xr-xdebian/rules18
-rw-r--r--debian/source/format1
-rw-r--r--debian/source/lintian-overrides2
-rw-r--r--debian/source/local-options2
-rw-r--r--debian/watch2
-rw-r--r--src/Makefile6
-rw-r--r--src/etc/xdg/autostart/logout-manager-trayicon.desktop13
-rwxr-xr-xsrc/usr/bin/logout-manager-cli.py1
-rwxr-xr-xsrc/usr/bin/logout-manager-trayicon163
-rw-r--r--src/usr/share/applications/logout-manager-trayicon.desktop12
25 files changed, 279 insertions, 126 deletions
diff --git a/README.md b/README.md
index aa626bb..0e69c79 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,5 @@
# Overview for logout-manager
See the [full readme](src/usr/share/doc/logout-manager/README.md) farther down in the source tree.
+
+## Alt directory
+The `alt` directory contains alternative files, including a shell script implementation of logout-manager-trayicon, which depends on `mktrayicon`.
diff --git a/alt/logout-manager-trayicon.sh b/alt/logout-manager-trayicon.sh
new file mode 100755
index 0000000..22cca5f
--- /dev/null
+++ b/alt/logout-manager-trayicon.sh
@@ -0,0 +1,83 @@
+#!/usr/bin/env sh
+# File: logout-manager-trayicon.sh
+# License: CC-BY-SA 4.0
+# Author: bgstack15
+# Startdate: 2020-03-19 13:34
+# Title: Tray icon for logout-manager
+# Purpose: To show a tray icon for logout options
+# History:
+# Alternative version of a trayicon that depends on mktrayicon
+# Usage:
+# Reference:
+# keyboard-leds-trayicons
+# Improve:
+# Dependencies:
+# raw: mktrayicon, awk, xset
+# devuan: mktrayicon, mawk | gawk, x11-xserver-utils
+# Documentation:
+# This script works just fine. I just want to learn how to do this in python, and have icons on the menu.
+
+# CONFIG FILES
+test -z "${LMT_GLOBAL_CONF}" && LMT_GLOBAL_CONF=/etc/logout-manager-trayicon.conf
+test -z "${LMT_USER_CONF}" && LMT_USER_CONF="${HOME}/.config/logout-manager-trayicon.conf"
+# also accept LMT_CONF
+
+# FUNCTIONS
+
+get_conf() {
+ # Ripped from framework.sh
+ # call: get_conf "${conffile}"
+ local _infile="$1"
+ local _tmpfile1="$( mktemp )"
+ sed -e 's/^\s*//;s/\s*$//;/^[#$]/d;s/\s*[^\]#.*$//;' "${_infile}" | grep -viE "^$" | while read _line ;
+ do
+ local _left="$( echo "${_line}" | cut -d'=' -f1 )"
+ eval "_thisval=\"\${${_left}}\""
+ test -z "${_thisval}" && echo "${_line}" >> "${_tmpfile1}"
+ done
+ test -f "${_tmpfile1}" && { . "${_tmpfile1}" 1>/dev/null 2>&1 ; }
+ /bin/rm -rf "${_tmpfile1}" 1>/dev/null 2>&1
+}
+
+clean_lmt() {
+ { test -e "${lmicon}" && echo "q" > "${lmicon}" ; } 1>/dev/null 2>&1 &
+}
+
+# LOAD CONFIGS
+# order is important! The last one called gets precedence.
+# instead of simply dot-sourcing the conf file, pass it to get_conf which only applies new values, so this process's environment is preserved
+for thisconf in "${LMT_GLOBAL_CONF}" "${LMT_USER_CONF}" "${LMT_CONF}" ;
+do
+ test -r "${thisconf}" && get_conf "${thisconf}"
+done
+
+# DEFAULTS in case configs did not have these values
+test -z "${LMT_ICON}" && LMT_ICON=logout
+
+# INITIALIZATION
+
+lmicon="/var/run/user/$( id -u )/${$}.logout-manager.icon"
+
+case "${1}" in
+ "run-program")
+ result="$( ps -eo 'pid,user,command:80' | grep -E 'logout-manager --from-[t]rayicon' | awk '{print $1}' )"
+ if test -n "${result}"
+ then
+ kill "${result}"
+ else
+ /usr/bin/logout-manager --from-trayicon
+ fi
+ ;;
+ *)
+ test "ON" = "ON" && {
+ mkfifo "${lmicon}"
+ mktrayicon "${lmicon}" &
+ echo "i ${LMT_ICON}" > "${lmicon}"
+ echo "m lock,logout-manager-cli.py lock|logout,logout-manager-cli.py logout|hibernate,logout-manager-cli.py hibernate|shutdown,logout-manager-cli.py shutdown|reboot,logout-manager-cli.py reboot|-----|Logged in as ${USER}|hide tray icon,echo 'q' > ${lmicon} ; kill -10 $$ 1>/dev/null 2>&1" > "${lmicon}"
+ echo "c $0 run-program" > "${lmicon}"
+ echo "t ${DRYRUN:+DRYRUN MODE: }Logged in as $USER" > "${lmicon}"
+ }
+ ;;
+esac
+
+trap 'trap "" 2 10 ; clean_lmt' 2 10 # CTRL-C SIGUSR1
diff --git a/debian/README.Debian b/debian/README.Debian
deleted file mode 100644
index 810fad6..0000000
--- a/debian/README.Debian
+++ /dev/null
@@ -1,5 +0,0 @@
-logout-manager for Devuan
-
-No changes
-
- -- Ben Stack <bgstack15@gmail.com> Wed, 11 Mar 2020 08:38:11 -0400
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index b206280..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-logout-manager (0.0.1-1) obs; urgency=low
-
- * Initial release.
-
- -- Ben Stack <bgstack15@gmail.com> Wed, 11 Mar 2020 08:38:11 -0400
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 48082f7..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-12
diff --git a/debian/control b/debian/control
deleted file mode 100644
index f7edf05..0000000
--- a/debian/control
+++ /dev/null
@@ -1,17 +0,0 @@
-Source: logout-manager
-Section: x11
-Priority: optional
-Maintainer: Ben Stack <bgstack15@gmail.com>
-Build-Depends: debhelper (>=12~)
-Standards-Version: 4.1.4
-Homepage: https://bgstack15.wordpress.com/
-
-Package: logout-manager
-Architecture: all
-Multi-Arch: foreign
-Depends: ${misc:Depends}, ${shlibs:Depends}
-Description: provide simple menu for logout-type actions
- Designed for minimal DEs and window managers that
- lack a menu for logging out, this tool provides
- such a menu.
-
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 6b39eaf..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,29 +0,0 @@
-Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: logout-manager
-Source: <url://example.com>
-#
-# Please double check copyright with the licensecheck(1) command.
-
-Files: .gitignore
- README.md
- src/Makefile
- src/etc/bash_completion.d/logout-manager
- src/etc/logout-manager.conf
- src/etc/sudoers.d/30_logout-manager_sudo
- src/etc/sysconfig/logout-manager
- src/usr/bin/logout-manager-cli.py
- src/usr/bin/logout-manager-gtk.py
- src/usr/bin/logout-manager-ncurses.py
- src/usr/bin/logout-manager-tcl.py
- src/usr/libexec/logout-manager/lm-helper
- src/usr/share/applications/logout-manager.desktop
- src/usr/share/doc/logout-manager/README.md
- src/usr/share/doc/logout-manager/logout-manager.conf.example
- src/usr/share/logout-manager/__pycache__/lmlib.cpython-37.pyc
- src/usr/share/logout-manager/lmlib.py
-Copyright: __NO_COPYRIGHT_NOR_LICENSE__
-License: __NO_COPYRIGHT_NOR_LICENSE__
-
-#----------------------------------------------------------------------------
-# Files marked as NO_LICENSE_TEXT_FOUND may be covered by the following
-# license/copyright files.
diff --git a/debian/do-not-install b/debian/do-not-install
deleted file mode 100644
index e752d8b..0000000
--- a/debian/do-not-install
+++ /dev/null
@@ -1 +0,0 @@
-usr/bin/logout-manager
diff --git a/debian/logout-manager.conffiles b/debian/logout-manager.conffiles
deleted file mode 100644
index 65e8592..0000000
--- a/debian/logout-manager.conffiles
+++ /dev/null
@@ -1,2 +0,0 @@
-etc/logout-manager.conf
-etc/default/logout-manager
diff --git a/debian/logout-manager.dsc b/debian/logout-manager.dsc
deleted file mode 100644
index 63ef881..0000000
--- a/debian/logout-manager.dsc
+++ /dev/null
@@ -1,14 +0,0 @@
-Format: 3.0 (quilt)
-Source: logout-manager
-Binary: logout-manager
-Architecture: all
-Version: 0.0.1-1
-Maintainer: Ben Stack <bgstack15@gmail.com>
-Homepage: https://bgstack15.wordpress.com/
-Standards-Version: 4.1.4
-Build-Depends: debhelper (>= 12~)
-Package-List:
- logout-manager deb x11 optional arch=all
-Files:
- 00000000000000000000000000000000 1 logout-manager.orig.tar.gz
- 00000000000000000000000000000000 1 logout-manager.debian.tar.xz
diff --git a/debian/logout-manager.install b/debian/logout-manager.install
deleted file mode 100644
index e69de29..0000000
--- a/debian/logout-manager.install
+++ /dev/null
diff --git a/debian/logout-manager.lintian-overrides b/debian/logout-manager.lintian-overrides
deleted file mode 100644
index 01f15e1..0000000
--- a/debian/logout-manager.lintian-overrides
+++ /dev/null
@@ -1,4 +0,0 @@
-binary-without-manpage
-copyright-has-url-from-dh_make-boilerplate
-copyright-without-copyright-notice
-script-with-language-extension
diff --git a/debian/logout-manager.postinst b/debian/logout-manager.postinst
deleted file mode 100644
index b98d697..0000000
--- a/debian/logout-manager.postinst
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh -e
-#DEBHELPER#
-case "$1" in
- configure|abort-upgrade|abort-remove|abort-deconfigure)
- update-alternatives --install /usr/bin/logout-manager logout-manager /usr/bin/logout-manager-gtk.py 80
- update-alternatives --install /usr/bin/logout-manager logout-manager /usr/bin/logout-manager-tcl.py 70
- update-alternatives --install /usr/bin/logout-manager logout-manager /usr/bin/logout-manager-ncurses.py 60
- ;;
-esac
diff --git a/debian/logout-manager.prerm b/debian/logout-manager.prerm
deleted file mode 100644
index c0c50d3..0000000
--- a/debian/logout-manager.prerm
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh -e
-#DEBHELPER#
-case "$1" in
- remove|deconfigure)
- update-alternatives --remove logout-manager /usr/bin/logout-manager-gtk.py
- update-alternatives --remove logout-manager /usr/bin/logout-manager-tcl.py
- update-alternatives --remove logout-manager /usr/bin/logout-manager-ncurses.py
- ;;
- upgrade|failed-upgrade)
- ;;
-esac
diff --git a/debian/patches/series b/debian/patches/series
deleted file mode 100644
index 4a97dfa..0000000
--- a/debian/patches/series
+++ /dev/null
@@ -1 +0,0 @@
-# You must remove unused comment lines for the released package.
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index c1fee5d..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/make -f
-# You must remove unused comment lines for the released package.
-#export DH_VERBOSE = 1
-#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
-#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
-#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
-APPNAME=logout-manager
-
-%:
- dh $@ --sourcedirectory=src
-
-override_dh_auto_install:
- dh_auto_install -- prefix=/usr DEFAULTDIR='$$(DESTDIR)/etc/default'
-
-override_dh_gencontrol:
- printf "misc:Depends=" > debian/${APPNAME}.substvars
- make -C src deplist DISTRO=devuan SEPARATOR=',' | grep -vE 'make\[[0-9]' >> debian/${APPNAME}.substvars
- dh_gencontrol
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides
deleted file mode 100644
index 2da37ed..0000000
--- a/debian/source/lintian-overrides
+++ /dev/null
@@ -1,2 +0,0 @@
-file-without-copyright-information
-missing-license-paragraph-in-dep5-copyright
diff --git a/debian/source/local-options b/debian/source/local-options
deleted file mode 100644
index 00131ee..0000000
--- a/debian/source/local-options
+++ /dev/null
@@ -1,2 +0,0 @@
-#abort-on-upstream-changes
-#unapply-patches
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index fc70498..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,2 +0,0 @@
-# You must remove unused comment lines for the released package.
-version=4
diff --git a/src/Makefile b/src/Makefile
index 96607d2..010b71e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -18,7 +18,7 @@
# Dependencies:
APPNAME = logout-manager
-APPVERSION = 0.0.1
+APPVERSION = 0.0.2
SRCDIR = $(CURDIR)
prefix = /usr
SYSCONFDIR = $(DESTDIR)/etc
@@ -32,6 +32,7 @@ APPDIR = $(SHAREDIR)/$(APPNAME)
APPSDIR = $(SHAREDIR)/applications
BASHCDIR = $(SHAREDIR)/bash-completion/completions
SUDOERSDIR = $(SYSCONFDIR)/sudoers.d
+XDGAUTODIR = $(SYSCONFDIR)/xdg/autostart
awkbin :=$(shell which awk)
cpbin :=$(shell which cp)
@@ -67,7 +68,7 @@ install:
@${echobin} Installing files to ${DESTDIR}
${installbin} -d ${SYSCONFDIR} ${DEFAULTDIR} ${BINDIR} \
${APPSDIR} ${APPDIR} ${DOCDIR} ${BASHCDIR} ${SUDOERSDIR} \
- ${LIBEXECDIR}/${APPNAME}
+ ${LIBEXECDIR}/${APPNAME} ${XDGAUTODIR}
${cpbin} -pr ${SRCDIR}/etc/*.* ${SYSCONFDIR}
${cpbin} -pr ${SRCDIR}/etc/sysconfig/* ${DEFAULTDIR}
${cpbin} -pr ${SRCDIR}/usr/bin/* ${BINDIR}
@@ -77,6 +78,7 @@ install:
${installbin} -m 0644 -t ${BASHCDIR} ${SRCDIR}/usr/share/bash-completion/completions/*
${installbin} -m 0640 -t ${SUDOERSDIR} ${SRCDIR}/etc/sudoers.d/*
${installbin} -m 0755 -t ${LIBEXECDIR}/${APPNAME} ${SRCDIR}/usr/libexec/${APPNAME}/*
+ ${installbin} -m 0644 -t ${XDGAUTODIR} ${SRCDIR}/etc/xdg/autostart/*
# symlink, when alternatives is not being used
${lnbin} -s logout-manager-gtk.py ${BINDIR}/logout-manager
diff --git a/src/etc/xdg/autostart/logout-manager-trayicon.desktop b/src/etc/xdg/autostart/logout-manager-trayicon.desktop
new file mode 100644
index 0000000..a1c5713
--- /dev/null
+++ b/src/etc/xdg/autostart/logout-manager-trayicon.desktop
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Categories=Utility;TrayIcon;
+Comment=Shows tray icon for easy logout options
+Exec=/usr/bin/logout-manager-trayicon
+GenericName=Logout menu on a tray icon
+Icon=system-log-out
+Keywords=shutdown;hibernate;lockscreen;logout;reboot;
+Name=Logout manager tray icon
+StartupNotify=true
+Terminal=false
+Type=Application
+Version=1.0
+Hidden=true
diff --git a/src/usr/bin/logout-manager-cli.py b/src/usr/bin/logout-manager-cli.py
index 64ea133..8fd78b4 100755
--- a/src/usr/bin/logout-manager-cli.py
+++ b/src/usr/bin/logout-manager-cli.py
@@ -60,6 +60,7 @@ if config.can_hibernate:
if args.action in allowed_actions:
func = getattr(globals()['actions'],args.action)
func(config)
+ sys.exit(0)
elif args.action:
eprint("Unable to take action: %s" % str(args.action))
sys.exit(1)
diff --git a/src/usr/bin/logout-manager-trayicon b/src/usr/bin/logout-manager-trayicon
new file mode 100755
index 0000000..b6471f9
--- /dev/null
+++ b/src/usr/bin/logout-manager-trayicon
@@ -0,0 +1,163 @@
+#!/usr/bin/env python3
+# File: logout-manager-trayicon
+# License: CC-BY-SA 4.0
+# Author: bgstack15
+# Reference:
+# icon work https://stackoverflow.com/questions/45162862/how-do-i-set-an-icon-for-the-whole-application-using-pygobject
+# button right click must be from "button-press-event" and import Gdk https://python-gtk-3-tutorial.readthedocs.io/en/latest/menus.html
+# useful reference https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Button.html#Gtk.Button
+# systray info https://github.com/PiSupply/PiJuice/blob/master/Software/Source/src/pijuice_tray.py
+# logout-manager-gtk.py
+# how to determine double click https://stackoverflow.com/questions/60009648/is-there-a-better-way-to-handle-double-click-in-pygobject
+# interactive python3 shell and help(Gdk.EventType)
+# https://developer.gnome.org/gtk3/unstable/GtkWidget.html#GtkWidget-button-press-event
+# find running processes https://thispointer.com/python-get-list-of-all-running-processes-and-sort-by-highest-memory-usage/
+# send signals https://stackoverflow.com/questions/15080500/how-can-i-send-a-signal-from-a-python-program
+# https://docs.python.org/3.8/library/signal.html#module-signal
+# Dependencies:
+# dep-pip: psutil
+# dep-devuan: python3-psutil
+
+import gi, os, platform, re, sys, psutil, signal
+gi.require_version("Gtk","3.0")
+from gi.repository import Gtk
+from gi.repository import Gdk
+from dotenv import load_dotenv
+
+# all this to load the libpath
+try:
+ defaultdir="/etc/sysconfig"
+ thisplatform = platform.platform().lower()
+ if 'debian' in thisplatform or 'devuan' in thisplatform:
+ defaultdir="/etc/default"
+ # load_dotenv keeps existing environment variables as higher precedent
+ load_dotenv(os.path.join(defaultdir,"logout-manager"))
+except:
+ pass
+if 'LOGOUT_MANAGER_LIBPATH' in os.environ:
+ for i in os.environ['LOGOUT_MANAGER_LIBPATH'].split(":"):
+ sys.path.append(i)
+import lmlib
+
+def is_dryrun():
+ result = False
+ try:
+ if "DRYRUN" in os.environ and os.environ["DRYRUN"] != "": result = True
+ except:
+ pass
+ return result
+
+def run_or_kill_logout_manager():
+ #print("Run or kill logout manager!")
+ _lm_is_running = False
+ lmregex = re.compile("logout-manager.*--from-trayicon")
+ lmprintregex = re.compile("logout-manager")
+ thisproc = None
+ for proc in psutil.process_iter():
+ try:
+ cmdline = " ".join(proc.cmdline())
+ #if lmprintregex.search(cmdline) != None: print("Checking \"" + cmdline + "\"")
+ if lmregex.search(cmdline) != None:
+ _lm_is_running = True
+ thisproc = proc
+ break
+ except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
+ pass
+
+ if _lm_is_running:
+ #print("Stopping the following process.")
+ #print(thisproc)
+ os.kill(thisproc.pid,signal.SIGHUP)
+ else:
+ # start new instance
+ #print("Please start a new instance")
+
+ # this actually returns the new pid, and we could choose to signal only this pid.
+ # but we will not at this point.
+ newpid = os.spawnvp(os.P_NOWAIT,"logout-manager",["logout-manager","--from-trayicon"])
+ print("spawned",newpid)
+
+class MainIcon(Gtk.StatusIcon):
+ def __init__(self,config,actions):
+ Gtk.StatusIcon.__init__(self)
+ self.config = config
+ self.actions = actions
+ self.set_from_icon_name(self.config.get_logout_icon())
+ loggedin_str = "Logged in as " + str(os.environ["USER"])
+ tooltiptext = loggedin_str
+ if is_dryrun():
+ tooltiptext = "DRYRUN MODE: " + tooltiptext
+ self.set_tooltip_text(tooltiptext)
+
+ self.traymenu = Gtk.Menu()
+ self.add_action_to_menu("Loc_k",self.config.get_lock_icon(),self.on_lock_menuitem)
+ self.add_action_to_menu("_Logout",self.config.get_logout_icon(),self.on_logout_menuitem)
+ self.add_action_to_menu("_Hibernate",self.config.get_hibernate_icon(),self.on_hibernate_menuitem)
+ self.add_action_to_menu("_Shutdown",self.config.get_shutdown_icon(),self.on_shutdown_menuitem)
+ self.add_action_to_menu("_Reboot",self.config.get_reboot_icon(),self.on_reboot_menuitem)
+
+ # separator
+ i = Gtk.SeparatorMenuItem.new()
+ i.show()
+ self.traymenu.append(i)
+
+ # logged in as
+ i = Gtk.MenuItem.new_with_label(tooltiptext)
+ i.set_sensitive(False)
+ i.show()
+ self.traymenu.append(i)
+
+ # hide tray icon
+ i = Gtk.MenuItem.new_with_mnemonic("Hide _tray icon")
+ i.show()
+ i.connect("activate", self.exit)
+ self.traymenu.append(i)
+
+ self.connect("button-press-event", self.on_button_press_event)
+ self.connect("popup-menu", self.show_menu)
+
+ def on_button_press_event(self, b_unknown, event: Gdk.EventButton):
+ if Gdk.EventType._2BUTTON_PRESS == event.type:
+ run_or_kill_logout_manager()
+
+ def exit(self, widget):
+ quit()
+
+ def show_menu(self, widget, event_button, event_time):
+ self.traymenu.popup(None, None,
+ self.position_menu,
+ self,
+ event_button,
+ Gtk.get_current_event_time())
+
+ def on_lock_menuitem(self, widget):
+ self.actions.lock(self.config)
+
+ def on_logout_menuitem(self, widget):
+ self.actions.logout(self.config)
+
+ def on_hibernate_menuitem(self, widget):
+ self.actions.hibernate(self.config)
+
+ def on_shutdown_menuitem(self, widget):
+ self.actions.shutdown(self.config)
+
+ def on_reboot_menuitem(self, widget):
+ self.actions.reboot(self.config)
+
+ def add_action_to_menu(self,label_str,icon_str,function_func):
+ i = Gtk.ImageMenuItem.new_with_mnemonic(label_str)
+ j = Gtk.Image.new_from_icon_name(icon_str,32)
+ j.show()
+ i.set_image(j)
+ i.set_always_show_image(True)
+ i.show()
+ i.connect("activate", function_func)
+ self.traymenu.append(i)
+
+# load configs
+config = lmlib.Initialize_config(os.environ['LOGOUT_MANAGER_CONF'])
+actions = lmlib.Actions
+
+icon = MainIcon(config,actions)
+Gtk.main()
diff --git a/src/usr/share/applications/logout-manager-trayicon.desktop b/src/usr/share/applications/logout-manager-trayicon.desktop
new file mode 100644
index 0000000..0379a29
--- /dev/null
+++ b/src/usr/share/applications/logout-manager-trayicon.desktop
@@ -0,0 +1,12 @@
+[Desktop Entry]
+Categories=Utility;TrayIcon;
+Comment=Shows tray icon for easy logout options
+Exec=/usr/bin/logout-manager-trayicon
+GenericName=Logout menu on a tray icon
+Icon=system-log-out
+Keywords=shutdown;hibernate;lockscreen;logout;reboot;
+Name=Logout manager tray icon
+StartupNotify=true
+Terminal=false
+Type=Application
+Version=1.0
bgstack15