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

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