-
Notifications
You must be signed in to change notification settings - Fork 2
/
tk_logout.py
executable file
·52 lines (35 loc) · 1.4 KB
/
tk_logout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
"""
*****************************************************************
tk_logout.py - equk.co.uk
*****************************************************************
Copyright (C) 2014 Bradley Walden
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See GNU GPLv3.
*****************************************************************
Brings up a logout / shutdown dialog for i3wm
*****************************************************************
Dependencies: Python3, Tkinter
Notes: add the line below to your i3 config to enable a floating window
for_window [class="Tk" title="tk_logout"] floating enable, border 1pixel
"""
import tkinter as tk
import os
def shutdown():
os.system("systemctl poweroff")
def reboot():
os.system("systemctl reboot")
def logout():
os.system("i3-msg exit")
app = tk.Tk()
app.title("tk_logout")
shutdown_button = tk.Button(app, text="Shutdown", command=shutdown)
shutdown_button.pack(side='left', padx=5, pady=5)
logout_button = tk.Button(app, text="Logout", command=logout)
logout_button.pack(side='left', padx=5, pady=5)
reboot_button = tk.Button(app, text="Reboot", command=reboot)
reboot_button.pack(side='left', padx=5, pady=5)
close_button = tk.Button(app, text="Close", command=exit)
close_button.pack(side='left', padx=5, pady=5)
app.mainloop()