From 10e99c43cdf4a0713b4e81d90691d22c6a58bdf2 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sat, 28 Dec 2024 11:16:56 +0100 Subject: [PATCH] copyq: add option to disable XWayland --- modules/services/copyq.nix | 9 ++++++++- tests/default.nix | 1 + .../services/copyq/basic-configuration.nix | 17 +++++++++++++++++ .../services/copyq/basic-expected.service | 12 ++++++++++++ tests/modules/services/copyq/default.nix | 4 ++++ .../copyq/dont-force-x-configuration.nix | 17 +++++++++++++++++ .../copyq/dont-force-x-expected.service | 11 +++++++++++ 7 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/modules/services/copyq/basic-configuration.nix create mode 100644 tests/modules/services/copyq/basic-expected.service create mode 100644 tests/modules/services/copyq/default.nix create mode 100644 tests/modules/services/copyq/dont-force-x-configuration.nix create mode 100644 tests/modules/services/copyq/dont-force-x-expected.service diff --git a/modules/services/copyq.nix b/modules/services/copyq.nix index 32e83978..6c412204 100644 --- a/modules/services/copyq.nix +++ b/modules/services/copyq.nix @@ -25,6 +25,13 @@ in { otherwise the service may never be started. ''; }; + + forceXWayland = lib.mkOption { + type = lib.types.bool; + default = true; + example = false; + description = "Force the CopyQ to use the X backend on wayland"; + }; }; config = lib.mkIf cfg.enable { @@ -45,7 +52,7 @@ in { Service = { ExecStart = "${cfg.package}/bin/copyq"; Restart = "on-failure"; - Environment = [ "QT_QPA_PLATFORM=xcb" ]; + Environment = lib.optional cfg.forceXWayland "QT_QPA_PLATFORM=xcb"; }; Install = { WantedBy = [ cfg.systemdTarget ]; }; diff --git a/tests/default.nix b/tests/default.nix index 177610e5..68474f22 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -243,6 +243,7 @@ in import nmtSrc { ./modules/services/cliphist ./modules/services/clipman ./modules/services/comodoro + ./modules/services/copyq ./modules/services/conky ./modules/services/darkman ./modules/services/devilspie2 diff --git a/tests/modules/services/copyq/basic-configuration.nix b/tests/modules/services/copyq/basic-configuration.nix new file mode 100644 index 00000000..f9087281 --- /dev/null +++ b/tests/modules/services/copyq/basic-configuration.nix @@ -0,0 +1,17 @@ +{ ... }: + +{ + config = { + services.copyq = { + enable = true; + systemdTarget = "sway-session.target"; + }; + + test.stubs.copyq = { }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/copyq.service + assertFileContent $serviceFile ${./basic-expected.service} + ''; + }; +} diff --git a/tests/modules/services/copyq/basic-expected.service b/tests/modules/services/copyq/basic-expected.service new file mode 100644 index 00000000..f20c23bb --- /dev/null +++ b/tests/modules/services/copyq/basic-expected.service @@ -0,0 +1,12 @@ +[Install] +WantedBy=sway-session.target + +[Service] +Environment=QT_QPA_PLATFORM=xcb +ExecStart=@copyq@/bin/copyq +Restart=on-failure + +[Unit] +After=graphical-session.target +Description=CopyQ clipboard management daemon +PartOf=graphical-session.target diff --git a/tests/modules/services/copyq/default.nix b/tests/modules/services/copyq/default.nix new file mode 100644 index 00000000..816fa880 --- /dev/null +++ b/tests/modules/services/copyq/default.nix @@ -0,0 +1,4 @@ +{ + copyq-basic-configuration = ./basic-configuration.nix; + copyq-dont-force-x = ./dont-force-x-configuration.nix; +} diff --git a/tests/modules/services/copyq/dont-force-x-configuration.nix b/tests/modules/services/copyq/dont-force-x-configuration.nix new file mode 100644 index 00000000..a233ae26 --- /dev/null +++ b/tests/modules/services/copyq/dont-force-x-configuration.nix @@ -0,0 +1,17 @@ +{ ... }: + +{ + config = { + services.copyq = { + enable = true; + forceXWayland = false; + }; + + test.stubs.copyq = { }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/copyq.service + assertFileContent $serviceFile ${./dont-force-x-expected.service} + ''; + }; +} diff --git a/tests/modules/services/copyq/dont-force-x-expected.service b/tests/modules/services/copyq/dont-force-x-expected.service new file mode 100644 index 00000000..7680f1fe --- /dev/null +++ b/tests/modules/services/copyq/dont-force-x-expected.service @@ -0,0 +1,11 @@ +[Install] +WantedBy=graphical-session.target + +[Service] +ExecStart=@copyq@/bin/copyq +Restart=on-failure + +[Unit] +After=graphical-session.target +Description=CopyQ clipboard management daemon +PartOf=graphical-session.target