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 ""
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2021-02-18 00:50+0000\n"
"Last-Translator: Kristjan Räts <kristjanrats@gmail.com>\n"
"PO-Revision-Date: 2024-11-12 23:00+0000\n"
"Last-Translator: Priit Jõerüüt <hwlate@joeruut.com>\n"
"Language-Team: Estonian <https://hosted.weblate.org/projects/safe-eyes/"
"translations/et/>\n"
"Language: et\n"
@ -15,11 +15,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.5\n"
"X-Generator: Weblate 5.9-dev\n"
# Short break
msgid "Gently close your eyes"
msgstr ""
msgstr "Sulge õrnalt oma silmad"
# Short break
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 "
"to take breaks while you're working long hours at the computer"
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"
# About dialog
@ -112,11 +112,11 @@ msgstr "Litsents"
# About dialog
msgid "List of Contributors"
msgstr ""
msgstr "Kaasautorite loend"
# About dialog
msgid "Help us translate this app"
msgstr ""
msgstr "Aita meil seda rakendust tõlkida"
# Break screen
msgid "Skip"
@ -128,7 +128,7 @@ msgstr "Lükka edasi"
# Settings dialog
msgid "Break duration (in seconds)"
msgstr "Pausi kestvus (sekundites)"
msgstr "Pausi kestus (sekundites)"
# Settings dialog
msgid "Interval between two breaks (in minutes)"
@ -244,7 +244,7 @@ msgstr "Palun vali pilt"
# Settings dialog
msgid "Duration"
msgstr "Kestvus"
msgstr "Kestus"
# Settings dialog
msgid "Time to wait"
@ -256,11 +256,11 @@ msgstr "Muuda vaikimisi seadeid"
# Settings dialog
msgid "Time (in seconds)"
msgstr "Kestvus (sekundites)"
msgstr "Kestus (sekundites)"
# Settings dialog
msgid "Time (in minutes)"
msgstr "Kestvus (minutites)"
msgstr "Kestus (minutites)"
# Settings dialog
msgid "Break Settings"
@ -497,15 +497,15 @@ msgstr "Tee nüüd paus"
#: plugins/trayicon
msgid "Any break"
msgstr ""
msgstr "Iga puhkepaus"
#: plugins/trayicon
msgid "Short break"
msgstr ""
msgstr "Lühike puhkepaus"
#: plugins/trayicon
msgid "Long break"
msgstr ""
msgstr "Pikk puhkepaus"
#: plugins/trayicon
msgid "Until restart"
@ -529,57 +529,61 @@ msgstr "Peata meedia"
# plugin/limitconsecutiveskipping
msgid "Limit Consecutive Skipping"
msgstr ""
msgstr "Piira järjest vahelejätmisi"
# plugin/limitconsecutiveskipping
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
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
#, python-format
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
msgid "RSI Prevention"
msgstr ""
msgstr "RSI ennetus"
msgid ""
"Please install service providing tray icons for your desktop environment."
msgstr ""
"Palun paigalda teenus, mis võimaldab sinu töölauakeskkonnas kasutada "
"süsteemisalve."
#, python-format
msgid "Next long break at %s"
msgstr ""
msgstr "Järgmine pikk puhkepaus %s"
#, python-format
msgid "Next breaks at %(short)s/%(long)s"
msgstr ""
msgstr "Järgmised puhkepausid %(short)s/%(long)s"
#, python-format
msgid "The required plugin '%s' is missing dependencies!"
msgstr ""
msgstr "Vajalikul „%s“ pluginal puuduvad sõltuvad komponendid!"
msgid ""
"Please install the dependencies or disable the plugin. To hide this message, "
"you can also deactivate the plugin in the settings."
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"
msgstr ""
msgstr "Lisateabeks klõpsi siin"
msgid "Disable plugin temporarily"
msgstr ""
msgstr "Lülita plugin ajutiselt välja"
msgid "Disable permanently"
msgstr ""
msgstr "Lülita püsivalt välja"
msgid "License:"
msgstr ""
msgstr "Litsents:"
# Short break
#~ msgid "Tightly close your eyes"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \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"
"Language-Team: French <https://hosted.weblate.org/projects/safe-eyes/"
"translations/fr/>\n"
@ -15,7 +15,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\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
msgid "Gently close your eyes"
@ -117,7 +117,7 @@ msgstr "Liste des contributeurs"
# About dialog
msgid "Help us translate this app"
msgstr ""
msgstr "Aidez-nous à traduire cette appli"
# Break screen
msgid "Skip"
@ -526,7 +526,7 @@ msgstr "Jusquau redémarrage"
#: plugins/trayicon
msgid "Quit"
msgstr "Fermer"
msgstr "Quitter"
# plugin/mediacontrol
msgid "Media Control"

View File

@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
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
@ -27,10 +26,9 @@ import re
import subprocess
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk
from gi.repository import GdkX11 # noqa F401
gi.require_version('Gio', '2.0')
from gi.repository import Gio
import Xlib
from safeeyes import utility
context = None
@ -63,36 +61,59 @@ def is_active_window_skipped_xorg(pre_break):
This method must be executed by the main thread. If not, it will cause random failure.
"""
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:
active_xid = str(active_window.get_xid())
cmdlist = ['xprop', '-root', '-notype', '-id',
active_xid, 'WM_CLASS', '_NET_WM_STATE']
NET_WM_STATE = x11_display.intern_atom("_NET_WM_STATE")
NET_WM_STATE_FULLSCREEN = x11_display.intern_atom("_NET_WM_STATE_FULLSCREEN")
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:
process_name = process_names[1].lower()
if _window_class_matches(process_name, skip_break_window_classes):
return True
elif _window_class_matches(process_name, take_break_window_classes):
if is_fullscreen and unfullscreen_allowed and not pre_break:
try:
active_window.unfullscreen()
except BaseException as e:
logging.error('Error in unfullscreen the window ' + process_name, exc_info=e)
return False
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()
return is_fullscreen
process_names = active_window.get_wm_class()
if is_fullscreen:
logging.info("fullscreen window found")
if process_names:
process_name = process_names[1].lower()
if _window_class_matches(process_name, skip_break_window_classes):
logging.info("found uninterruptible window")
return True
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:
logging.info("interrupting interruptible window")
try:
# 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:
logging.error('Error in unfullscreen the window ' + process_name, exc_info=e)
return False
return is_fullscreen
return False