Skip to content

Commit

Permalink
Use a shell script to launch, where the environment can be checked
Browse files Browse the repository at this point in the history
before x11 resources are loaded in python.

This prevents cinnamon-screensaver crashes when attempting to
launch it in wayland. This will let it abort cleanly.
  • Loading branch information
mtwebster committed Jan 18, 2024
1 parent 81a1866 commit 5e225dc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
8 changes: 8 additions & 0 deletions src/binfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
echo "cinnamon-screensaver is disabled in wayland sessions. Exiting."
exit 1
fi

exec @install_dir@/@target@ $@
7 changes: 0 additions & 7 deletions src/cinnamon-screensaver-command.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@ def perform_action(self):
self.mainloop.quit()

if __name__ == "__main__":
try:
if os.environ["WAYLAND_DISPLAY"]:
print("Cinnamon Screensaver is unavailable on Wayland.")
sys.exit(0)
except KeyError:
pass

ml = GLib.MainLoop.new(None, True)
main = ScreensaverCommand(ml)

Expand Down
9 changes: 0 additions & 9 deletions src/cinnamon-screensaver-main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
import setproctitle
import sys

# Do this before importing ScreensaverService as that triggers all of the dbus services
# including the XAppKbdLayoutController which is x11 only.
try:
if os.environ["WAYLAND_DISPLAY"]:
print("Cinnamon Screensaver is unavailable on Wayland.")
sys.exit(0)
except KeyError:
pass

import config
import status
from util import utils, settings
Expand Down
29 changes: 21 additions & 8 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,31 @@ app_css = [
'cinnamon-screensaver.css',
]

install_data(app_py + app_css,
install_dir: pkgdatadir
)

app_scripts = [
['cinnamon-screensaver-main.py', 'cinnamon-screensaver'],
['cinnamon-screensaver-command.py', 'cinnamon-screensaver-command']
]

install_data(app_py + app_css,
install_dir: pkgdatadir
)

foreach script : app_scripts
install_data(script[0], install_dir: pkgdatadir)
meson.add_install_script('sh', '-c', 'mkdir -p "$DESTDIR/@0@"'.format(bindir))
meson.add_install_script('sh', '-c',
'ln -sf "@0@" "$DESTDIR/@1@"'.format(join_paths(pkgdatadir, script[0]), join_paths(bindir, script[1])))
prefix_info = configuration_data()
prefix_info.set('install_dir', pkgdatadir)
prefix_info.set('target', script[0])

bin_file = configure_file(
input : 'binfile.in',
output: script[1],
configuration: prefix_info,
install_dir: get_option('bindir'),
install_mode: 'rwxr-xr-x'
)

install_data(
script[0],
install_dir: pkgdatadir,
install_mode: 'rwxr-xr-x'
)
endforeach

0 comments on commit 5e225dc

Please sign in to comment.