iflen(selected_process_name)==15:# Linux kernel trims process names longer than 16 (TASK_COMM_LEN, see: https://man7.org/linux/man-pages/man5/proc.5.html) characters (it is counted as 15). "/proc/[PID]/cmdline/" file is read and it is split by the last "/" character (not all process cmdlines have this) in order to obtain full process name.
selected_process_name=reader.read().split("/")[-1].split("\x00")[0]# Some process names which are obtained from "cmdline" contain "\x00" and these are trimmed by using "split()".
exceptFileNotFoundError:
process_cmdline=reader.read()
selected_process_name=process_cmdline.split("/")[-1].split("\x00")[0]# Some process names which are obtained from "cmdline" contain "\x00" and these are trimmed by using "split()".
exceptFileNotFoundError:# Removed pid from "pid_list" and skip to next loop (pid) if process is ended just after pid_list is generated.
selected_process_name=process_name_from_stat# Root access is needed for reading "cmdline" file of the some processes. Otherwise it gives "" as output. Process name from "stat" file of the process is used is this situation. Also process name from "stat" file is used if name from "cmdline" does not start with name from "stat" file.
selected_process_name=process_cmdline.split(" ")[0].split("\x00")[0].strip()# Some process names which are obtained from "cmdline" contain "\x00" and these are trimmed by using "split()".
selected_process_name=process_name_from_stat# Root access is needed for reading "cmdline" file of the some processes. Otherwise it gives "" as output. Process name from "stat" file of the process is used is this situation. Also process name from "stat" file is used if name from "cmdline" does not start with name from "stat" file.
(subprocess.check_output("renice -n "+str(selected_process_nice)+" -p "+selected_process_pid,shell=True).strip()).decode()# It gives "renice: failed to set priority for [PID] (process ID): Access denied" output if application is not run with root privileges.
(subprocess.check_output("pkexec renice -n "+str(selected_process_nice)+" -p "+selected_process_pid,shell=True).strip()).decode()# It gives "renice: failed to set priority for [PID] (process ID): Access denied" output if application is not run with root privileges.
# Set Processes tab customizations popover menu Precision/Data Units tab GUI object data/selections appropriate for settings
# Add CPU usage percent data into combobox
if"liststore2101p"notinglobals():# Check if "liststore2101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.
if"liststore2101p"notinglobals():# Check if "liststore2101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.
# Set Storage tab customizations popover menu Precision/Data Units tab GUI object data/selections appropriate for settings
# Add Disk usage data precision into combobox
if"liststore4101p"notinglobals():# Check if "liststore4101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.
if"liststore4101p"notinglobals():# Check if "liststore4101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.