diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-03-19 21:10:37 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-03-19 21:10:37 +0100 |
commit | abde20daebee82abb754835d6f7c309f7aea3819 (patch) | |
tree | 0e9f36dec4c9656df67b373713b4a30a7e1c2f36 /portato/su.py | |
parent | 79586b7b6a02d0f88246574c943f9a01f4dd89b6 (diff) | |
download | portato-abde20daebee82abb754835d6f7c309f7aea3819.tar.gz portato-abde20daebee82abb754835d6f7c309f7aea3819.tar.bz2 portato-abde20daebee82abb754835d6f7c309f7aea3819.zip |
Add support for ktsuss as su frontend
Diffstat (limited to '')
-rw-r--r-- | portato/su.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/portato/su.py b/portato/su.py new file mode 100644 index 0000000..b87c75b --- /dev/null +++ b/portato/su.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# +# File: portato/su.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +from __future__ import with_statement, absolute_import + +import os + +from .constants import APP_ICON +from .helper import detect_desktop_environment + +class SUCommand (object): + def __init__ (self, bin, args): + self.bin = bin + self.args = args + + def cmd (self, cmd): + return [self.bin] + self.args + [cmd] + + def check (self): + for p in os.environ['PATH'].split(":"): + jp = os.path.join(p, self.bin) + if os.access(jp, os.F_OK): + return True + + return False + +class SplitSUCommand (SUCommand): + def cmd (self, cmd): + return [self.bin] + self.args + cmd.split() + +gtksu = SUCommand("gksu", ["-D", "Portato"]) +kdesu = SUCommand("kdesu", ["-t", "-d", "-i", APP_ICON, "-c"]) +ktsuss = SplitSUCommand("ktsuss", ["-m", "Portato"]) + +def detect_su_command (): + desktop_env = detect_desktop_environment() + if desktop_env == "kde": + sus = [kdesu, ktsuss, gtksu] + elif desktop_env == "gnome": + sus = [gtksu, ktsuss, kdesu] + else: + sus = [ktsuss, gtksu, kdesu] + + for s in sus: + if s.check(): + return s + + return None |