49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
from PyQt6.QtGui import QIcon, QAction
|
|
from PyQt6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
|
|
import os
|
|
import signal
|
|
|
|
# enable
|
|
# xset s on +dpms;xscreensaver --nosplash
|
|
# disable
|
|
# xset s off -dpms;xscreensaver-command -exit
|
|
|
|
app = QApplication([])
|
|
app.setQuitOnLastWindowClosed(False)
|
|
|
|
# Adding an icon
|
|
icon = QIcon("work.png")
|
|
|
|
# Adding item on the menu bar
|
|
tray = QSystemTrayIcon()
|
|
tray.setIcon(icon)
|
|
tray.setVisible(True)
|
|
|
|
# Creating the options
|
|
menu = QMenu()
|
|
|
|
|
|
# opción desactivar screensaver
|
|
def desactivar():
|
|
pidx = os.popen('pidof xscreensaver').read()
|
|
if pidx != "":
|
|
os.killpg(int(pidx), signal.SIGTERM)
|
|
pid4 = os.popen('pidof xfce4-screensaver').read()
|
|
if pid4 != "":
|
|
os.killpg(os.getpid(int(pid4)), signal.SIGTERM)
|
|
|
|
|
|
optionDesactivo = QAction("Desactivar salvapantallas")
|
|
optionDesactivo.triggered.connect(lambda: desactivar())
|
|
menu.addAction(optionDesactivo)
|
|
|
|
# To quit the app
|
|
quit = QAction("Quit")
|
|
quit.triggered.connect(app.quit)
|
|
menu.addAction(quit)
|
|
|
|
# Adding options to the System Tray
|
|
tray.setContextMenu(menu)
|
|
|
|
app.exec()
|