Inicio app
This commit is contained in:
BIN
cinema.png
Normal file
BIN
cinema.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
58
pyStScreen.py
Normal file
58
pyStScreen.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from PyQt6.QtGui import QIcon, QAction
|
||||
from PyQt6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
|
||||
import os
|
||||
|
||||
# enable
|
||||
# xset s on +dpms;xscreensaver --nosplash
|
||||
# disable
|
||||
# xset s off -dpms;xscreensaver-command -exit
|
||||
|
||||
# saber si se está ejecutando
|
||||
|
||||
|
||||
pid = os.popen('pidof xscreensaver').read()
|
||||
print(pid)
|
||||
matado = os.popen('kill {int(pid)}').read()
|
||||
print(matado)
|
||||
|
||||
|
||||
# Al iniciar se activa xscreensaver
|
||||
salida = os.popen(
|
||||
'xset s on +dpms;/usr/bin/xscreensaver --nosplash;echo ENABLE xscreensaver').read()
|
||||
print(salida)
|
||||
|
||||
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():
|
||||
salida = os.popen(
|
||||
'xset s off -dpms;xscreensaver-command -exit').read()
|
||||
print(salida)
|
||||
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user