Compare commits

...

4 Commits

Author SHA1 Message Date
deltragon c68ed8b47d
Merge 46af33faa2 into b0b624705e 2024-11-22 07:15:03 +00:00
AO Localisation Lab b0b624705e
Translated using Weblate (French)
Currently translated at 100.0% (135 of 135 strings)

Translation: Safe Eyes/Translations
Translate-URL: https://hosted.weblate.org/projects/safe-eyes/translations/fr/
2024-11-13 00:00:33 +01:00
Priit Jõerüüt ff79402a2f
Translated using Weblate (Estonian)
Currently translated at 100.0% (135 of 135 strings)

Translation: Safe Eyes/Translations
Translate-URL: https://hosted.weblate.org/projects/safe-eyes/translations/et/
2024-11-13 00:00:32 +01:00
deltragon 46af33faa2 donotdisturb: switch x11 fullscreen detection to Xlib
This is needed for Gtk4, as Gtk4 does not offer APIs to find/change
other applications' windows.
No functional change intended. This should keep the exact same behaviour
on X11 as the Gtk3 implementation, as it sends the same X events.
2024-10-02 19:18:13 +02:00
3 changed files with 85 additions and 60 deletions

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2021-02-18 00:50+0000\n" "PO-Revision-Date: 2024-11-12 23:00+0000\n"
"Last-Translator: Kristjan Räts <kristjanrats@gmail.com>\n" "Last-Translator: Priit Jõerüüt <hwlate@joeruut.com>\n"
"Language-Team: Estonian <https://hosted.weblate.org/projects/safe-eyes/" "Language-Team: Estonian <https://hosted.weblate.org/projects/safe-eyes/"
"translations/et/>\n" "translations/et/>\n"
"Language: et\n" "Language: et\n"
@ -15,11 +15,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.5\n" "X-Generator: Weblate 5.9-dev\n"
# Short break # Short break
msgid "Gently close your eyes" msgid "Gently close your eyes"
msgstr "" msgstr "Sulge õrnalt oma silmad"
# Short break # Short break
msgid "Roll your eyes a few times to each side" msgid "Roll your eyes a few times to each side"
@ -103,7 +103,7 @@ msgid ""
"Safe Eyes protects your eyes from eye strain (asthenopia) by reminding you " "Safe Eyes protects your eyes from eye strain (asthenopia) by reminding you "
"to take breaks while you're working long hours at the computer" "to take breaks while you're working long hours at the computer"
msgstr "" msgstr ""
"Safe Eyes aitab vähendada arvutiga töötamisel silmade väsimust, tuletades " "Safe Eyes aitab arvutiga töötamisel vähendada silmade väsimust, tuletades "
"meelde puhkepause" "meelde puhkepause"
# About dialog # About dialog
@ -112,11 +112,11 @@ msgstr "Litsents"
# About dialog # About dialog
msgid "List of Contributors" msgid "List of Contributors"
msgstr "" msgstr "Kaasautorite loend"
# About dialog # About dialog
msgid "Help us translate this app" msgid "Help us translate this app"
msgstr "" msgstr "Aita meil seda rakendust tõlkida"
# Break screen # Break screen
msgid "Skip" msgid "Skip"
@ -128,7 +128,7 @@ msgstr "Lükka edasi"
# Settings dialog # Settings dialog
msgid "Break duration (in seconds)" msgid "Break duration (in seconds)"
msgstr "Pausi kestvus (sekundites)" msgstr "Pausi kestus (sekundites)"
# Settings dialog # Settings dialog
msgid "Interval between two breaks (in minutes)" msgid "Interval between two breaks (in minutes)"
@ -244,7 +244,7 @@ msgstr "Palun vali pilt"
# Settings dialog # Settings dialog
msgid "Duration" msgid "Duration"
msgstr "Kestvus" msgstr "Kestus"
# Settings dialog # Settings dialog
msgid "Time to wait" msgid "Time to wait"
@ -256,11 +256,11 @@ msgstr "Muuda vaikimisi seadeid"
# Settings dialog # Settings dialog
msgid "Time (in seconds)" msgid "Time (in seconds)"
msgstr "Kestvus (sekundites)" msgstr "Kestus (sekundites)"
# Settings dialog # Settings dialog
msgid "Time (in minutes)" msgid "Time (in minutes)"
msgstr "Kestvus (minutites)" msgstr "Kestus (minutites)"
# Settings dialog # Settings dialog
msgid "Break Settings" msgid "Break Settings"
@ -497,15 +497,15 @@ msgstr "Tee nüüd paus"
#: plugins/trayicon #: plugins/trayicon
msgid "Any break" msgid "Any break"
msgstr "" msgstr "Iga puhkepaus"
#: plugins/trayicon #: plugins/trayicon
msgid "Short break" msgid "Short break"
msgstr "" msgstr "Lühike puhkepaus"
#: plugins/trayicon #: plugins/trayicon
msgid "Long break" msgid "Long break"
msgstr "" msgstr "Pikk puhkepaus"
#: plugins/trayicon #: plugins/trayicon
msgid "Until restart" msgid "Until restart"
@ -529,57 +529,61 @@ msgstr "Peata meedia"
# plugin/limitconsecutiveskipping # plugin/limitconsecutiveskipping
msgid "Limit Consecutive Skipping" msgid "Limit Consecutive Skipping"
msgstr "" msgstr "Piira järjest vahelejätmisi"
# plugin/limitconsecutiveskipping # plugin/limitconsecutiveskipping
msgid "How many skips or postpones are allowed in a row" msgid "How many skips or postpones are allowed in a row"
msgstr "" msgstr "Kui mitu edasilükkamist või vahelejätmist võid järjest teha"
# plugin/limitconsecutiveskipping # plugin/limitconsecutiveskipping
msgid "Limit how many breaks can be skipped or postponed in a row" msgid "Limit how many breaks can be skipped or postponed in a row"
msgstr "" msgstr "Kui mitu pausi võid järjest vahele jätta või edasi lükata"
# plugin/limitconsecutiveskipping # plugin/limitconsecutiveskipping
#, python-format #, python-format
msgid "Skipped or postponed %(num)d/%(allowed)d breaks in a row" msgid "Skipped or postponed %(num)d/%(allowed)d breaks in a row"
msgstr "" msgstr "Järjest vahelejäetud või edasilükatatud %(num)d/%(allowed)d pausi"
# safeeyes/platform/io.github.slgobinath.SafeEyes.desktop # safeeyes/platform/io.github.slgobinath.SafeEyes.desktop
msgid "RSI Prevention" msgid "RSI Prevention"
msgstr "" msgstr "RSI ennetus"
msgid "" msgid ""
"Please install service providing tray icons for your desktop environment." "Please install service providing tray icons for your desktop environment."
msgstr "" msgstr ""
"Palun paigalda teenus, mis võimaldab sinu töölauakeskkonnas kasutada "
"süsteemisalve."
#, python-format #, python-format
msgid "Next long break at %s" msgid "Next long break at %s"
msgstr "" msgstr "Järgmine pikk puhkepaus %s"
#, python-format #, python-format
msgid "Next breaks at %(short)s/%(long)s" msgid "Next breaks at %(short)s/%(long)s"
msgstr "" msgstr "Järgmised puhkepausid %(short)s/%(long)s"
#, python-format #, python-format
msgid "The required plugin '%s' is missing dependencies!" msgid "The required plugin '%s' is missing dependencies!"
msgstr "" msgstr "Vajalikul „%s“ pluginal puuduvad sõltuvad komponendid!"
msgid "" msgid ""
"Please install the dependencies or disable the plugin. To hide this message, " "Please install the dependencies or disable the plugin. To hide this message, "
"you can also deactivate the plugin in the settings." "you can also deactivate the plugin in the settings."
msgstr "" msgstr ""
"Palun lisa vajalikud komponendid või lülita plugin välja. Viimast saad teha "
"seadistustest ja sellega ei teki enam ka antud teadet."
msgid "Click here for more information" msgid "Click here for more information"
msgstr "" msgstr "Lisateabeks klõpsi siin"
msgid "Disable plugin temporarily" msgid "Disable plugin temporarily"
msgstr "" msgstr "Lülita plugin ajutiselt välja"
msgid "Disable permanently" msgid "Disable permanently"
msgstr "" msgstr "Lülita püsivalt välja"
msgid "License:" msgid "License:"
msgstr "" msgstr "Litsents:"
# Short break # Short break
#~ msgid "Tightly close your eyes" #~ msgid "Tightly close your eyes"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2024-08-24 17:09+0000\n" "PO-Revision-Date: 2024-11-12 23:00+0000\n"
"Last-Translator: AO Localisation Lab <ao@localizationlab.org>\n" "Last-Translator: AO Localisation Lab <ao@localizationlab.org>\n"
"Language-Team: French <https://hosted.weblate.org/projects/safe-eyes/" "Language-Team: French <https://hosted.weblate.org/projects/safe-eyes/"
"translations/fr/>\n" "translations/fr/>\n"
@ -15,7 +15,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n" "Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 5.7.1-dev\n" "X-Generator: Weblate 5.9-dev\n"
# Short break # Short break
msgid "Gently close your eyes" msgid "Gently close your eyes"
@ -117,7 +117,7 @@ msgstr "Liste des contributeurs"
# About dialog # About dialog
msgid "Help us translate this app" msgid "Help us translate this app"
msgstr "" msgstr "Aidez-nous à traduire cette appli"
# Break screen # Break screen
msgid "Skip" msgid "Skip"
@ -526,7 +526,7 @@ msgstr "Jusquau redémarrage"
#: plugins/trayicon #: plugins/trayicon
msgid "Quit" msgid "Quit"
msgstr "Fermer" msgstr "Quitter"
# plugin/mediacontrol # plugin/mediacontrol
msgid "Media Control" msgid "Media Control"

View File

@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
Skip Fullscreen plugin skips the break if the active window is fullscreen. Skip Fullscreen plugin skips the break if the active window is fullscreen.
NOTE: Do not remove the unused import 'GdkX11' because it is required in Ubuntu 14.04
""" """
import os import os
@ -27,10 +26,9 @@ import re
import subprocess import subprocess
import gi import gi
gi.require_version('Gdk', '3.0') gi.require_version('Gio', '2.0')
from gi.repository import Gdk
from gi.repository import GdkX11 # noqa F401
from gi.repository import Gio from gi.repository import Gio
import Xlib
from safeeyes import utility from safeeyes import utility
context = None context = None
@ -63,31 +61,54 @@ def is_active_window_skipped_xorg(pre_break):
This method must be executed by the main thread. If not, it will cause random failure. This method must be executed by the main thread. If not, it will cause random failure.
""" """
logging.info('Searching for full-screen application') logging.info('Searching for full-screen application')
screen = Gdk.Screen.get_default()
active_window = screen.get_active_window() x11_display = Xlib.display.Display()
active_window = x11_display.get_input_focus().focus
if active_window: if active_window:
active_xid = str(active_window.get_xid()) NET_WM_STATE = x11_display.intern_atom("_NET_WM_STATE")
cmdlist = ['xprop', '-root', '-notype', '-id', NET_WM_STATE_FULLSCREEN = x11_display.intern_atom("_NET_WM_STATE_FULLSCREEN")
active_xid, 'WM_CLASS', '_NET_WM_STATE']
props = active_window.get_full_property(NET_WM_STATE, Xlib.Xatom.ATOM)
is_fullscreen = props.value and NET_WM_STATE_FULLSCREEN in props.value.tolist()
process_names = active_window.get_wm_class()
if is_fullscreen:
logging.info("fullscreen window found")
try:
stdout = subprocess.check_output(cmdlist).decode('utf-8')
except subprocess.CalledProcessError:
logging.warning('Error in finding full-screen application')
else:
if stdout:
is_fullscreen = 'FULLSCREEN' in stdout
# Extract the process name
process_names = re.findall('"(.+?)"', stdout)
if process_names: if process_names:
process_name = process_names[1].lower() process_name = process_names[1].lower()
if _window_class_matches(process_name, skip_break_window_classes): if _window_class_matches(process_name, skip_break_window_classes):
logging.info("found uninterruptible window")
return True return True
elif _window_class_matches(process_name, take_break_window_classes): elif _window_class_matches(process_name, take_break_window_classes):
logging.info("found interruptible window")
if is_fullscreen and unfullscreen_allowed and not pre_break: if is_fullscreen and unfullscreen_allowed and not pre_break:
logging.info("interrupting interruptible window")
try: try:
active_window.unfullscreen() # To change the fullscreen state, we cannot simply set the property - we must send a ClientMessage event
# See https://specifications.freedesktop.org/wm-spec/1.3/ar01s05.html#id-1.6.8
root_window = x11_display.screen().root
cm_event = Xlib.protocol.event.ClientMessage(
window = active_window,
client_type = NET_WM_STATE,
data = (32, [
0, # _NET_WM_STATE_REMOVE
NET_WM_STATE_FULLSCREEN,
0, # other property, must be 0
1, # source indication
0 # must be 0
])
)
mask = Xlib.X.SubstructureRedirectMask | Xlib.X.SubstructureNotifyMask
root_window.send_event(cm_event, event_mask = mask)
x11_display.sync()
except BaseException as e: except BaseException as e:
logging.error('Error in unfullscreen the window ' + process_name, exc_info=e) logging.error('Error in unfullscreen the window ' + process_name, exc_info=e)
return False return False