Blame SOURCES/0002-Add-a-script-for-simplifying-kiosk-setup.patch

f5e75e
From db768718666563f5ad9658ba4cc07987122b4e89 Mon Sep 17 00:00:00 2001
f5e75e
From: Ray Strode <rstrode@redhat.com>
f5e75e
Date: Mon, 9 Aug 2021 10:30:36 -0400
f5e75e
Subject: [PATCH 2/2] Add a script for simplifying kiosk setup
f5e75e
f5e75e
This commit adds a new session "Kiosk Script Session" to the login
f5e75e
screen that starts a shell script that starts a gedit window that opens
f5e75e
the shell script.
f5e75e
f5e75e
It should make it easy to customize the session to use a bespoke
f5e75e
application from within the session itself.
f5e75e
---
f5e75e
 .../org.gnome.Kiosk.Script.desktop.in.in      |  4 ++
f5e75e
 kiosk-script/gnome-kiosk-script               | 23 +++++++
f5e75e
 .../gnome-session/gnome-kiosk-script.session  |  3 +
f5e75e
 .../systemd/org.gnome.Kiosk.Script.service.in |  8 +++
f5e75e
 kiosk-script/systemd/session.conf             |  3 +
f5e75e
 .../gnome-kiosk-script-wayland.desktop.in     |  9 +++
f5e75e
 .../gnome-kiosk-script-xorg.desktop.in        |  9 +++
f5e75e
 meson.build                                   | 61 ++++++++++++++++++-
f5e75e
 8 files changed, 118 insertions(+), 2 deletions(-)
f5e75e
 create mode 100644 kiosk-script/desktop/org.gnome.Kiosk.Script.desktop.in.in
f5e75e
 create mode 100755 kiosk-script/gnome-kiosk-script
f5e75e
 create mode 100644 kiosk-script/gnome-session/gnome-kiosk-script.session
f5e75e
 create mode 100644 kiosk-script/systemd/org.gnome.Kiosk.Script.service.in
f5e75e
 create mode 100644 kiosk-script/systemd/session.conf
f5e75e
 create mode 100644 kiosk-script/wayland-sessions/gnome-kiosk-script-wayland.desktop.in
f5e75e
 create mode 100644 kiosk-script/xsessions/gnome-kiosk-script-xorg.desktop.in
f5e75e
f5e75e
diff --git a/kiosk-script/desktop/org.gnome.Kiosk.Script.desktop.in.in b/kiosk-script/desktop/org.gnome.Kiosk.Script.desktop.in.in
f5e75e
new file mode 100644
f5e75e
index 0000000..dd562b2
f5e75e
--- /dev/null
f5e75e
+++ b/kiosk-script/desktop/org.gnome.Kiosk.Script.desktop.in.in
f5e75e
@@ -0,0 +1,4 @@
f5e75e
+[Desktop Entry]
f5e75e
+Name=Kiosk Script
f5e75e
+Type=Application
f5e75e
+Exec=gnome-kiosk-script
f5e75e
diff --git a/kiosk-script/gnome-kiosk-script b/kiosk-script/gnome-kiosk-script
f5e75e
new file mode 100755
f5e75e
index 0000000..b595cd8
f5e75e
--- /dev/null
f5e75e
+++ b/kiosk-script/gnome-kiosk-script
f5e75e
@@ -0,0 +1,23 @@
f5e75e
+#!/usr/bin/sh
f5e75e
+
f5e75e
+if [ ! -e ~/.local/bin/gnome-kiosk-script ]; then
f5e75e
+    mkdir -p ~/.local/bin ~/.config
f5e75e
+    cat > ~/.local/bin/gnome-kiosk-script <<- "EOF"
f5e75e
+	#!/bin/sh
f5e75e
+	# This script is located in ~/.local/bin.
f5e75e
+	# It's provided as an example script to show how
f5e75e
+	# the kiosk session works.  At the moment, the script
f5e75e
+	# just starts a text editor open to itself, but it
f5e75e
+	# should get customized to instead start a full screen
f5e75e
+	# application designed for the kiosk deployment.
f5e75e
+	gedit ~/.local/bin/gnome-kiosk-script
f5e75e
+
f5e75e
+	sleep 1.0
f5e75e
+	exec "$0" "$@"
f5e75e
+EOF
f5e75e
+
f5e75e
+    chmod +x ~/.local/bin/gnome-kiosk-script
f5e75e
+    touch ~/.config/gnome-initial-setup-done
f5e75e
+fi
f5e75e
+
f5e75e
+exec ~/.local/bin/gnome-kiosk-script "$@"
f5e75e
diff --git a/kiosk-script/gnome-session/gnome-kiosk-script.session b/kiosk-script/gnome-session/gnome-kiosk-script.session
f5e75e
new file mode 100644
f5e75e
index 0000000..3b2cc7b
f5e75e
--- /dev/null
f5e75e
+++ b/kiosk-script/gnome-session/gnome-kiosk-script.session
f5e75e
@@ -0,0 +1,3 @@
f5e75e
+[GNOME Session]
f5e75e
+Name=Kiosk
f5e75e
+RequiredComponents=org.gnome.Kiosk;org.gnome.Kiosk.Script;
f5e75e
diff --git a/kiosk-script/systemd/org.gnome.Kiosk.Script.service.in b/kiosk-script/systemd/org.gnome.Kiosk.Script.service.in
f5e75e
new file mode 100644
f5e75e
index 0000000..8194f1c
f5e75e
--- /dev/null
f5e75e
+++ b/kiosk-script/systemd/org.gnome.Kiosk.Script.service.in
f5e75e
@@ -0,0 +1,8 @@
f5e75e
+[Unit]
f5e75e
+Description=Kiosk script
f5e75e
+BindsTo=gnome-session.target
f5e75e
+After=gnome-session.target
f5e75e
+
f5e75e
+[Service]
f5e75e
+ExecStart=@bindir@/gnome-kiosk-script
f5e75e
+Restart=always
f5e75e
diff --git a/kiosk-script/systemd/session.conf b/kiosk-script/systemd/session.conf
f5e75e
new file mode 100644
f5e75e
index 0000000..a948efb
f5e75e
--- /dev/null
f5e75e
+++ b/kiosk-script/systemd/session.conf
f5e75e
@@ -0,0 +1,3 @@
f5e75e
+[Unit]
f5e75e
+Requires=org.gnome.Kiosk.target
f5e75e
+Requires=org.gnome.Kiosk.Script.service
f5e75e
diff --git a/kiosk-script/wayland-sessions/gnome-kiosk-script-wayland.desktop.in b/kiosk-script/wayland-sessions/gnome-kiosk-script-wayland.desktop.in
f5e75e
new file mode 100644
f5e75e
index 0000000..05e8dea
f5e75e
--- /dev/null
f5e75e
+++ b/kiosk-script/wayland-sessions/gnome-kiosk-script-wayland.desktop.in
f5e75e
@@ -0,0 +1,9 @@
f5e75e
+[Desktop Entry]
f5e75e
+Name=Kiosk Script Session (Wayland Display Server)
f5e75e
+Comment=This session logs you into the sessoin started by ~/.local/bin/gnome-kiosk-script
f5e75e
+Exec=gnome-session --session gnome-kiosk-script
f5e75e
+TryExec=gnome-session
f5e75e
+Type=Application
f5e75e
+DesktopNames=GNOME-Kiosk;GNOME;
f5e75e
+X-GDM-SessionRegisters=true
f5e75e
+
f5e75e
diff --git a/kiosk-script/xsessions/gnome-kiosk-script-xorg.desktop.in b/kiosk-script/xsessions/gnome-kiosk-script-xorg.desktop.in
f5e75e
new file mode 100644
f5e75e
index 0000000..11dc0cf
f5e75e
--- /dev/null
f5e75e
+++ b/kiosk-script/xsessions/gnome-kiosk-script-xorg.desktop.in
f5e75e
@@ -0,0 +1,9 @@
f5e75e
+[Desktop Entry]
f5e75e
+Name=Kiosk Script Session (X11 Display Server)
f5e75e
+Comment=This session logs you into the sessoin started by ~/.local/bin/gnome-kiosk-script
f5e75e
+Exec=gnome-session --session gnome-kiosk-script
f5e75e
+TryExec=gnome-session
f5e75e
+Type=Application
f5e75e
+DesktopNames=GNOME-Kiosk;GNOME;
f5e75e
+X-GDM-SessionRegisters=true
f5e75e
+
f5e75e
diff --git a/meson.build b/meson.build
f5e75e
index c2988ad..1f5a756 100644
f5e75e
--- a/meson.build
f5e75e
+++ b/meson.build
f5e75e
@@ -1,49 +1,50 @@
f5e75e
 project('gnome-kiosk', 'c',
f5e75e
         version: '40.0'
f5e75e
 )
f5e75e
 add_project_arguments('-D_GNU_SOURCE',
f5e75e
                       language: 'c'
f5e75e
 )
f5e75e
 
f5e75e
 c_compiler = meson.get_compiler('c')
f5e75e
 
f5e75e
 gnome = import('gnome')
f5e75e
 i18n = import('i18n')
f5e75e
 
f5e75e
 prefix = get_option('prefix')
f5e75e
 datadir = join_paths(prefix, get_option('datadir'))
f5e75e
 bindir = join_paths(prefix, get_option('bindir'))
f5e75e
 localedir = join_paths(datadir, 'locale')
f5e75e
 desktop_data_dir = join_paths(datadir, 'applications')
f5e75e
 session_dir = join_paths(datadir, 'gnome-session', 'sessions')
f5e75e
 xsessions_dir = join_paths(datadir, 'xsessions')
f5e75e
+wayland_sessions_dir = join_paths(datadir, 'wayland-sessions')
f5e75e
 
f5e75e
 po_dir = join_paths(meson.current_source_dir(), 'po')
f5e75e
 
f5e75e
 config_data = configuration_data()
f5e75e
 config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
f5e75e
 config_data.set_quoted('VERSION', meson.project_version())
f5e75e
 config_data.set_quoted('LOCALEDIR', localedir)
f5e75e
 
f5e75e
 config_h = configure_file(
f5e75e
         input: 'config.h.meson',
f5e75e
         output: 'config.h',
f5e75e
         configuration: config_data
f5e75e
 )
f5e75e
 
f5e75e
 meson.add_install_script ('meson/postinstall.py')
f5e75e
 
f5e75e
 mutter_dependency = dependency('libmutter-8')
f5e75e
 mutter_libdir = mutter_dependency.get_pkgconfig_variable('typelibdir')
f5e75e
 
f5e75e
 systemd_user_unit_dir = dependency('systemd').get_pkgconfig_variable('systemduserunitdir',
f5e75e
                                                                      define_variable: ['prefix', prefix])
f5e75e
 systemd_dependency = dependency('libsystemd')
f5e75e
 
f5e75e
 dbus_proxies = []
f5e75e
 dbus_proxies += {
f5e75e
         'prefix':   'org.gnome.DisplayManager',
f5e75e
         'namespace': 'Gdm',
f5e75e
         'interface': 'Manager',
f5e75e
 }
f5e75e
 
f5e75e
@@ -139,62 +140,118 @@ desktop_file = configure_file(
f5e75e
         input: 'compositor/data/org.gnome.Kiosk.desktop.in.in',
f5e75e
         output: 'org.gnome.Kiosk.desktop.in',
f5e75e
         configuration: desktop_config_data
f5e75e
 )
f5e75e
 
f5e75e
 i18n.merge_file('desktop',
f5e75e
         input: desktop_file,
f5e75e
         output: 'org.gnome.Kiosk.desktop',
f5e75e
         po_dir: po_dir,
f5e75e
         install: true,
f5e75e
         install_dir: desktop_data_dir,
f5e75e
         type: 'desktop'
f5e75e
 )
f5e75e
 
f5e75e
 systemd_service_config_data = configuration_data()
f5e75e
 systemd_service_config_data.set('bindir', bindir)
f5e75e
 
f5e75e
 systemd_service_files = []
f5e75e
 systemd_service_files += 'compositor/data/systemd/org.gnome.Kiosk@wayland.service.in'
f5e75e
 systemd_service_files += 'compositor/data/systemd/org.gnome.Kiosk@x11.service.in'
f5e75e
 
f5e75e
 foreach service_file : systemd_service_files
f5e75e
         configure_file(
f5e75e
                 input: service_file,
f5e75e
                 output: '@BASENAME@',
f5e75e
                 configuration: systemd_service_config_data,
f5e75e
                 install_dir: systemd_user_unit_dir
f5e75e
         )
f5e75e
 endforeach
f5e75e
 
f5e75e
-install_data('compositor/data/systemd/org.gnome.Kiosk.target',
f5e75e
-             install_dir: systemd_user_unit_dir)
f5e75e
+install_data(
f5e75e
+        'compositor/data/systemd/org.gnome.Kiosk.target',
f5e75e
+        install_dir: systemd_user_unit_dir
f5e75e
+)
f5e75e
+
f5e75e
+install_data('kiosk-script/gnome-kiosk-script',
f5e75e
+        install_dir: bindir,
f5e75e
+	install_mode: 'rwxr-xr-x'
f5e75e
+)
f5e75e
+
f5e75e
+desktop_file = configure_file(
f5e75e
+        input: 'kiosk-script/desktop/org.gnome.Kiosk.Script.desktop.in.in',
f5e75e
+        output: 'org.gnome.Kiosk.Script.desktop.in',
f5e75e
+        configuration: desktop_config_data
f5e75e
+)
f5e75e
+
f5e75e
+i18n.merge_file('desktop',
f5e75e
+        input: desktop_file,
f5e75e
+        output: 'org.gnome.Kiosk.Script.desktop',
f5e75e
+        po_dir: po_dir,
f5e75e
+        install: true,
f5e75e
+        install_dir: desktop_data_dir,
f5e75e
+        type: 'desktop'
f5e75e
+)
f5e75e
+
f5e75e
+configure_file(
f5e75e
+       input: 'kiosk-script/systemd/org.gnome.Kiosk.Script.service.in',
f5e75e
+       output: '@BASENAME@',
f5e75e
+       configuration: systemd_service_config_data,
f5e75e
+       install_dir: systemd_user_unit_dir
f5e75e
+)
f5e75e
+
f5e75e
+kiosk_script_systemd_target_dir = join_paths(systemd_user_unit_dir, 'gnome-session@gnome-kiosk-script.target.d')
f5e75e
+install_data('kiosk-script/systemd/session.conf',
f5e75e
+        install_dir: kiosk_script_systemd_target_dir
f5e75e
+)
f5e75e
+
f5e75e
+install_data('kiosk-script/gnome-session/gnome-kiosk-script.session',
f5e75e
+        install_dir: session_dir,
f5e75e
+)
f5e75e
+
f5e75e
+i18n.merge_file('desktop',
f5e75e
+        input: 'kiosk-script/xsessions/gnome-kiosk-script-xorg.desktop.in',
f5e75e
+        output: '@BASENAME@',
f5e75e
+        po_dir: po_dir,
f5e75e
+        install: true,
f5e75e
+        install_dir: xsessions_dir,
f5e75e
+        type: 'desktop'
f5e75e
+)
f5e75e
+
f5e75e
+i18n.merge_file('desktop',
f5e75e
+        input: 'kiosk-script/wayland-sessions/gnome-kiosk-script-wayland.desktop.in',
f5e75e
+        output: '@BASENAME@',
f5e75e
+        po_dir: po_dir,
f5e75e
+        install: true,
f5e75e
+        install_dir: wayland_sessions_dir,
f5e75e
+        type: 'desktop'
f5e75e
+)
f5e75e
 
f5e75e
 session_config_data = configuration_data()
f5e75e
 session_config_data.set('required_components', 'org.gnome.Kiosk;org.gnome.Kiosk.SearchApp;')
f5e75e
 
f5e75e
 session_file = configure_file(
f5e75e
         input: 'search-app/org.gnome.Kiosk.SearchApp.session.desktop.in.in',
f5e75e
         output: 'org.gnome.Kiosk.SearchApp.session.desktop.in',
f5e75e
         configuration: session_config_data
f5e75e
 )
f5e75e
 
f5e75e
 subdir('input-selector')
f5e75e
 
f5e75e
 i18n.merge_file('desktop',
f5e75e
         input: session_file,
f5e75e
         output: 'org.gnome.Kiosk.SearchApp.session',
f5e75e
         po_dir: po_dir,
f5e75e
         install: true,
f5e75e
         install_dir: session_dir,
f5e75e
         type: 'desktop'
f5e75e
 )
f5e75e
 
f5e75e
 i18n.merge_file('desktop',
f5e75e
         input: 'search-app/org.gnome.Kiosk.SearchApp.Session.desktop.in',
f5e75e
         output: 'org.gnome.Kiosk.SearchApp.Session.desktop',
f5e75e
         po_dir: po_dir,
f5e75e
         install: true,
f5e75e
         install_dir: xsessions_dir,
f5e75e
         type: 'desktop'
f5e75e
 )
f5e75e
 
f5e75e
-- 
f5e75e
2.31.1
f5e75e