From 3c7a0379431e4a6d0f3a4997c0ecc4c2f3d8895c Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Mon, 10 Nov 2025 06:08:24 +0300
Subject: twin/compton: use SIGUSR1 to reload settings

Before that to reload settings compton-tde was using SIGUSR2; and
SIGUSR1 wasn't actully used, but was designated for something wierd.
This commit removes old SIGUSR1 handler and uses SIGUSR1 to reload the
settings instead of SIGUSR2.

Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tdebase/issues/673
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 twin/compton-tde/compton.c | 26 +-------------------------
 twin/workspace.cpp         |  6 +++---
 2 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/twin/compton-tde/compton.c b/twin/compton-tde/compton.c
index 533dc2c61..f8bed3af4 100644
--- a/twin/compton-tde/compton.c
+++ b/twin/compton-tde/compton.c
@@ -157,33 +157,10 @@ void delete_pid_file()
 
 void handle_siguser (int sig)
 {
-    int uidnum;
     if (sig == SIGTERM) {
         delete_pid_file();
         exit(0);
-    }
-    if (sig == SIGUSR1) {
-        char newuid[1024];
-#ifndef NDEBUG
-        printf("Enter the new user ID:\n"); fflush(stdout);
-#endif
-        char *eof;
-        newuid[0] = '\0';
-        newuid[sizeof(newuid)-1] = '\0';
-        eof = fgets(newuid, sizeof(newuid), stdin);
-        uidnum = atoi(newuid);
-#ifndef NDEBUG
-        printf("Setting compton-tde process uid to %d...\n", uidnum); fflush(stdout);
-#endif
-
-        delete_pid_file();
-        setuid(uidnum);
-        write_pid_file(getpid());
-    }
-    else {
-        uidnum = getuid();
-    }
-    if ((sig == SIGUSR1) || (sig == SIGUSR2)) {
+    } else if (sig == SIGUSR1) {
         /* force redetection of the configuration file location */
         if (ps_g->o.config_file) {
           free(ps_g->o.config_file);
@@ -8556,7 +8533,6 @@ main(int argc, char **argv) {
   usr_action.sa_mask = block_mask;
   usr_action.sa_flags = 0;
   sigaction(SIGUSR1, &usr_action, NULL);
-  sigaction(SIGUSR2, &usr_action, NULL);
   sigaction(SIGTERM, &usr_action, NULL);
 
   // Main loop
diff --git a/twin/workspace.cpp b/twin/workspace.cpp
index c6d7dd121..7b9571a9a 100644
--- a/twin/workspace.cpp
+++ b/twin/workspace.cpp
@@ -1118,14 +1118,14 @@ void Workspace::slotReconfigure()
         {
         bool tmp = options->useTranslucency;
 
-        // If compton-tde is already running, sending SIGUSR2 will force a reload of its settings
+        // If compton-tde is already running, sending SIGUSR1 will force a reload of its settings
         pid_t kompmgrpid = getCompositorPID();
 
         if (tmp)
             {
             if (kompmgrpid)
                 {
-                kill(kompmgrpid, SIGUSR2);
+                kill(kompmgrpid, SIGUSR1);
                 }
             else
                 {
@@ -2981,7 +2981,7 @@ void Workspace::kompmgrReloadSettings()
     if (!kompmgr || !kompmgr->isRunning()) {
         return;
     }
-    kompmgr->kill(SIGUSR2);
+    kompmgr->kill(SIGUSR1);
 }
 
 bool Workspace::kompmgrIsRunning()
-- 
cgit v1.2.3

