From 92bcc5aabd92001b4f05ce13875422066bf82732 Mon Sep 17 00:00:00 2001
From: Sparky Bluefang <sparky@bluefang-logic.com>
Date: Wed, 3 Jul 2024 02:13:13 -0400
Subject: [PATCH] Optionally install wayland session files

---
 data/meson.build  | 13 +++++++------
 meson.build       | 11 ++++++++---
 meson_options.txt |  5 +++++
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/data/meson.build b/data/meson.build
index f46bf967fb..807ea218a8 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -16,11 +16,10 @@ desktop_conf.set('bindir', join_paths(prefix, bindir))
 desktop_conf.set('libexecdir', join_paths(prefix, libexecdir))
 desktop_conf.set('VERSION', meson.project_version())
 
-desktop_files = [
-  'cinnamon.desktop',
-  'cinnamon-wayland.desktop',
-  'cinnamon2d.desktop',
-]
+desktop_files = ['cinnamon.desktop', 'cinnamon2d.desktop']
+if get_option('wayland')
+    desktop_files += ['cinnamon-wayland.desktop']
+endif
 
 foreach desktop_file : desktop_files
     desktop = configure_file(
@@ -40,7 +39,9 @@ foreach desktop_file : desktop_files
 endforeach
 
 subdir('xdg-portal')
-subdir('wayland_sessions')
+if get_option('wayland')
+    subdir('wayland_sessions')
+endif
 subdir('xsessions')
 subdir('services')
 
diff --git a/meson.build b/meson.build
index d7705c0919..7b4c74c528 100644
--- a/meson.build
+++ b/meson.build
@@ -165,10 +165,15 @@ else
     session_conf.set('REQUIRED', '')
 endif
 
-foreach file : ['cinnamon.session', 'cinnamon2d.session', 'cinnamon-wayland.session']
+session_files = ['cinnamon.session', 'cinnamon2d.session']
+if get_option('wayland')
+    session_files += ['cinnamon-wayland.session']
+endif
+
+foreach session_file : session_files
     configure_file(
-        input: file + '.in',
-        output: file,
+        input: session_file + '.in',
+        output: session_file,
         configuration: session_conf,
         install_dir: join_paths(prefix, datadir, 'cinnamon-session', 'sessions'),
     )
diff --git a/meson_options.txt b/meson_options.txt
index 82422246b0..321192d8c6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -23,4 +23,9 @@ option('py3modules_dir',
     value : '',
     description: 'Where to install python3 modules'
 )
+option('wayland',
+    type : 'boolean',
+    value : true,
+    description: 'Enable wayland support'
+)