Last active
February 4, 2021 20:22
-
-
Save rodrigo-x/32bc46f45ca313ec0499794ab20346e5 to your computer and use it in GitHub Desktop.
Logout and Shutdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import gi | |
gi.require_version("Gtk", "3.0") | |
from gi.repository import Gtk | |
class Shutdown(Gtk.Window): | |
def __init__(self): | |
Gtk.Window.__init__(self, title="Desligar o PC") | |
self.set_border_width(10) | |
self.set_size_request(300,50) | |
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) | |
hbox = Gtk.Box(spacing=6) | |
self.add(hbox) | |
button = Gtk.ToggleToolButton(label="Desligar", use_underline=True) | |
#button.set_active(True) | |
button.connect("toggled", self.on_button_one_toggled, "1") | |
hbox.pack_start(button, True, True, 0) | |
button = Gtk.ToggleToolButton(label="Logout", use_underline=True) | |
#button.set_active(True) | |
button.connect("toggled", self.on_button_two_toggled, "2") | |
hbox.pack_start(button, True, True, 0) | |
def on_button_one_toggled(self, button): | |
if button.get_active(): | |
os.system('shutdown -h now') | |
def on_button_two_toggled(self, button): | |
if button.get_active(): | |
os.system('pkill -U $USER') | |
win = Shutdown() | |
win.connect("destroy", Gtk.main_quit) | |
win.show_all() | |
Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment