mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 03:02:16 +03:00
get display number method has been added for gnome desktop env
This commit is contained in:
parent
51dd82ebd9
commit
18193c3c97
5 changed files with 33 additions and 6 deletions
|
@ -430,6 +430,24 @@ class Util:
|
|||
display_number = ":"+str(display_number)
|
||||
return display_number
|
||||
|
||||
@staticmethod
|
||||
def get_username_display_gnome(user):
|
||||
result_code, p_out, p_err = Util.execute("who | awk '{print $1, $5}' | sed 's/(://' | sed 's/)//'", result=True)
|
||||
display_number = None
|
||||
result = []
|
||||
lines = str(p_out).split('\n')
|
||||
for line in lines:
|
||||
arr = line.split(' ')
|
||||
if len(arr) > 1 and str(arr[1]).isnumeric() is True:
|
||||
result.append(line)
|
||||
for res in result:
|
||||
arr = res.split(" ")
|
||||
username = arr[0]
|
||||
if username == user:
|
||||
display_number = ":" + arr[1]
|
||||
# print("--->>> dis no: " + str(display_number))
|
||||
return display_number
|
||||
|
||||
@staticmethod
|
||||
def get_desktop_env():
|
||||
xfce4_session = "/usr/bin/xfce4-session"
|
||||
|
|
|
@ -102,16 +102,21 @@ class RunConkyCommand(AbstractPlugin):
|
|||
self.create_file(self.conky_config_global_autorun_file)
|
||||
self.write_file(self.conky_config_global_autorun_file, self.conky_autorun_content)
|
||||
|
||||
users=self.Sessions.user_name()
|
||||
users = self.Sessions.user_name()
|
||||
desktop_env = self.get_desktop_env()
|
||||
self.logger.info("Get desktop environment is {0}".format(desktop_env))
|
||||
|
||||
for user in users:
|
||||
user_display = self.Sessions.display(user)
|
||||
if desktop_env == "gnome":
|
||||
user_display = self.get_username_display_gnome(user)
|
||||
|
||||
if user_display is None:
|
||||
self.logger.debug('[Conky] executing for display none for user '+ str(user))
|
||||
self.execute('conky -q', result=False)
|
||||
else :
|
||||
else:
|
||||
self.logger.debug('[Conky] user display ' + str(user_display) +' user '+ str(user))
|
||||
conky_cmd= 'su ' + str(user) + ' -c ' + ' "conky --display=' + str(user_display) + ' " '
|
||||
conky_cmd = 'su ' + str(user) + ' -c ' + ' "conky --display=' + str(user_display) + ' " '
|
||||
self.logger.debug('[Conky] executing command: ' + str(conky_cmd))
|
||||
self.execute(conky_cmd, result=False)
|
||||
|
||||
|
|
|
@ -26,12 +26,16 @@ class RunXMessageCommand(AbstractPlugin):
|
|||
|
||||
def execute_xmessage(self, message):
|
||||
|
||||
users = self.Sessions.user_name();
|
||||
users = self.Sessions.user_name()
|
||||
self.logger.debug('[XMessage] users : ' + str(users))
|
||||
desktop_env = self.get_desktop_env()
|
||||
self.logger.info("Get desktop environment is {0}".format(desktop_env))
|
||||
|
||||
for user in users:
|
||||
user_display = self.Sessions.display(user)
|
||||
user_ip = self.Sessions.userip(user)
|
||||
if desktop_env == "gnome":
|
||||
user_display = self.get_username_display_gnome(user)
|
||||
|
||||
if user_display is None:
|
||||
self.logger.debug('[XMessage] executing for display none for user ' + str(user))
|
||||
|
|
|
@ -15,7 +15,7 @@ function log() {
|
|||
}
|
||||
|
||||
if [ -n $PAM_USER ] && [ $PAM_USER != "root" ]; then
|
||||
if ([ -n $PAM_SERVICE ] && [[ $PAM_SERVICE == *"dm" ]]) || ([ -n $PAM_TTY ] && [[ $PAM_TTY == ":"* ]]); then
|
||||
if ([ -n $PAM_SERVICE ] && [[ ( $PAM_SERVICE == *"dm" || $PAM_SERVICE == "gdm"* )]]) || ([ -n $PAM_TTY ] && [[ $PAM_TTY == ":"* ]]); then
|
||||
SERVICE="none"
|
||||
if [ -n $PAM_SERVICE ]; then
|
||||
SERVICE="$PAM_SERVICE"
|
||||
|
|
|
@ -15,7 +15,7 @@ function log() {
|
|||
}
|
||||
|
||||
if [ -n $PAM_USER ] && [ $PAM_USER != "root" ]; then
|
||||
if ([ -n $PAM_SERVICE ] && [[ $PAM_SERVICE == *"dm" ]]) || ([ -n $PAM_TTY ] && [[ $PAM_TTY == ":"* ]]); then
|
||||
if ([ -n $PAM_SERVICE ] && [[ ( $PAM_SERVICE == "gdm"* || $PAM_SERVICE == *"dm" )]]) || ([ -n $PAM_TTY ] && [[ $PAM_TTY == ":"* ]]); then
|
||||
SERVICE="none"
|
||||
if [ -n $PAM_SERVICE ]; then
|
||||
SERVICE="$PAM_SERVICE"
|
||||
|
|
Loading…
Reference in a new issue