mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-28 08:02:15 +03:00
added get user display number methode
This commit is contained in:
parent
18149fc4d2
commit
ef97266358
1 changed files with 26 additions and 3 deletions
|
@ -338,13 +338,20 @@ class Util:
|
||||||
Util.execute('export DISPLAY={0}; su - {1} -c \'{2}\''.format(display, user, inner_command))
|
Util.execute('export DISPLAY={0}; su - {1} -c \'{2}\''.format(display, user, inner_command))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show_message(username,display=':0',message='', title=''):
|
def show_message(username, display, message='', title=''):
|
||||||
ask_path = Util.get_ask_path_file()+ 'confirm.py'
|
ask_path = Util.get_ask_path_file()+ 'confirm.py'
|
||||||
|
|
||||||
|
Scope.get_instance().get_logger().debug('DISPLAYYYY --------->>>>>>>>: ' + str(display))
|
||||||
|
|
||||||
|
if display is None:
|
||||||
|
display_number = Util.get_username_display()
|
||||||
|
else:
|
||||||
|
display_number = display
|
||||||
try:
|
try:
|
||||||
|
|
||||||
if username is not None:
|
if username is not None:
|
||||||
command = 'su - {0} -c \'python3 {1} \"{2}\" \"{3}\" \"{4}\"\''.format(username, ask_path, message,
|
command = 'su - {0} -c \'python3 {1} \"{2}\" \"{3}\" \"{4}\"\''.format(username, ask_path, message,
|
||||||
title, display)
|
title, display_number)
|
||||||
result_code, p_out, p_err = Util.execute(command)
|
result_code, p_out, p_err = Util.execute(command)
|
||||||
|
|
||||||
if p_out.strip() == 'Y':
|
if p_out.strip() == 'Y':
|
||||||
|
@ -368,7 +375,8 @@ class Util:
|
||||||
|
|
||||||
ask_path = Util.get_ask_path_file()+ 'ahenkmessage.py'
|
ask_path = Util.get_ask_path_file()+ 'ahenkmessage.py'
|
||||||
|
|
||||||
display_number = ":0"
|
# display_number = ":0"
|
||||||
|
display_number = Util.get_username_display()
|
||||||
|
|
||||||
if host is None:
|
if host is None:
|
||||||
command = 'su - {0} -c \"python3 {1} \'{2}\' \'{3}\' \'{4}\' \"'.format(login_user_name,
|
command = 'su - {0} -c \"python3 {1} \'{2}\' \'{3}\' \'{4}\' \"'.format(login_user_name,
|
||||||
|
@ -396,3 +404,18 @@ class Util:
|
||||||
|
|
||||||
return pout
|
return pout
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_username_display():
|
||||||
|
result_code, p_out, p_err = Util.execute("who | awk '{print $1, $5}' | sed 's/(//' | sed 's/)//'", result=True)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
params = str(result[0]).split(' ')
|
||||||
|
display_number = params[1]
|
||||||
|
return display_number
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue