<commit_before>#!/usr/bin/python3
#A quick and dirty interface to end a session - assumes systemd
#By <NAME>

from tkinter import *
import os
import sys

def getLogoutCommand() :
    #Logout command can be specified as a program argument. Without arguments
    #the command is taken as pkill -u $USER
    args = sys.argv
    if len(args) == 1 : return "pkill -u $USER"
    else : return args[1]

def runAction() :
    if option.get() == 1 : 
        os.system(getLogoutCommand())
        os._exit(0)
    elif option.get() == 2 : 
        os.system("systemctl suspend")
        os._exit(0)
    elif option.get() == 3 : 
        os.system("systemctl hibernate")
        os._exit(0)
    elif option.get() == 4 : 
        os.system("systemctl reboot")
        os._exit(0)
    elif option.get() == 5 : 
        os.system("systemctl poweroff")
        os._exit(0)
        
class UI() :
    def __init__(self, parent) :
        parent.title("End session")
        global option
        option = IntVar()
        r1 = Radiobutton(parent, text = "Logout", variable = option, value = 1).grid(row = 2, column = 1)<commit_msg>end-session.py - change default logout command to loginctl terminate-session. this is cleaner than using pkill<commit_after>#!/usr/bin/python3
#A quick and dirty interface to end a session - assumes systemd
#By <NAME>

from tkinter import *
import os
import sys

def getLogoutCommand() :
    #Logout command can be specified as a program argument. Without arguments
    #the command is taken as loginctl terminate-session $XDG_SESSION_ID
    args = sys.argv
    if len(args) == 1 : return "loginctl terminate-session $XDG_SESSION_ID"
    else : return args[1]

def runAction() :
    if option.get() == 1 : 
        os.system(getLogoutCommand())
        os._exit(0)
    elif option.get() == 2 : 
        os.system("systemctl suspend")
        os._exit(0)
    elif option.get() == 3 : 
        os.system("systemctl hibernate")
        os._exit(0)
    elif option.get() == 4 : 
        os.system("systemctl reboot")
        os._exit(0)
    elif option.get() == 5 : 
        os.system("systemctl poweroff")
        os._exit(0)
        
class UI() :
    def __init__(self, parent) :
        parent.title("End session")
        global option
        option = IntVar()
        r1 = Radiobutton(parent, text = "Logout", variable = option, value = 1).grid(row = 2, column = 1)
{'fraction_non_alphanumeric': 0.12053758924821503, 'fraction_numerical': 0.014279714405711887, 'mean_word_length': 2.4926686217008798, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1013989', 'n_tokens_mistral': 778, 'n_tokens_neox': 736, 'n_words': 226}