1

After suffering from a bug in Redshift, I found a great replacement, Iris.

I have put the Iris folder in my home directory, and added the following command to Startup Applications sh /home/arun/Iris/Iris.sh.

That all works splendidly, but upon startup, the settings GUI window also launches. All I really need is the little panel indicator icon. Sort of like the "Hide" function in OS X's "Login Items".

Can this be achieved?

Fiksdal
  • 2,121

1 Answers1

1

The Iris settingswindow

If we close Iris' settings window with the X, it is seemingly closed.

If we do the same, with the help of wmctrl (wmctrl -ic <window_id>) however, it turns out not only the window is closed, but the complete application.

My conclusion is then that the window is not actually closed, but unmapped when we press the X.

We can do the same with the help of xdotool. With an edited version of this answer: How can I run a program on startup, minimized?, we can then startup Iris without the settings window to appear.

Starting up iris without the settings window (script)

  1. The script uses both wmctrl and xdotool:

    sudo apt-get install wmctrl xdotool
    
  2. Copy the script below into an empty file, save it into the same directory as your Iris.sh file (so they are together in the same directory), as start_iris.py.

    #!/usr/bin/env python3
    import subprocess
    import time
    import sys
    import os
    
    command = os.path.dirname(sys.argv[0])+"/Iris.sh"
    subprocess.Popen(["/bin/bash", "-c", command])
    
    def get(cmd):
        return subprocess.check_output(cmd).decode("utf-8").strip()
    
    t = 0
    
    while t < 12:
        time.sleep(1)
        try:
            w_list = [l.split()[0] for l in get(["wmctrl", "-l"]).splitlines() if "Iris" in l]
            for w in w_list:
                check = [l for l in get(["xprop", "-id", w]).splitlines()\
                         if "WM_CLASS(STRING)" in l][0]
                if "Iris" in check:
                    subprocess.Popen(["xdotool", "windowunmap", w])
                    break
            break
        except (IndexError, subprocess.CalledProcessError):
            pass
        t += 1
    
  3. Now run the following command instead of the original command to start Iris:

    python3 /path/to/start_iris.py
    

The settings window will no longer appear!

Explanation

  • The script looks into its own directory for the file Iris.sh, and launches it.
  • Subsequently, it watches for the creation of new windows of WM_CLASS Iris (your settings window).
  • If it found the targeted window, it unmaps the window with the xdotool command:

    xdotool windowunmap <window_id>
    

Notes

  1. Obviously, clicking on the X of the settings window also unmaps the window.
    Apparantly this is done in a different way from xdotool. The consequence is that you cannot reach the settings window (from the indicator menu), without restarting Iris.

    You mentioned however you normally do not need the settings window at all.

  2. Note that when starting up GUI applications from Startup APplications (especially when it involves screen settings), you might need to build in a little break for it to work fine. If it doesn't work from Startup Applications, change the command to add to Stratup Applications into:

    /bin/bash -c "sleep 10 && python3 /path/to/start_iris.py"
    
Jacob Vlijm
  • 83,767
  • This worked. The sleep was necessary. It is a slight disadvange that I am not able to open the window when I do need it. But I have an idea for that: We can make a script that kills Iris and relaunches it again, with the GUI, and then assign that script to a keyboard shortcut. What is the command for killing off Iris? – Fiksdal Mar 31 '16 at 19:23
  • @Fiksdal If you really want, it can be made more elegant to remap the window without a restart, but it would take a shortcut key for example. Would you find that a good solution? – Jacob Vlijm Mar 31 '16 at 19:28
  • I would actually, but I just now talked to the Iris developer and he has sent me modified version of the program that launches as a panel icon without any window :) So now it's all good. Thanks for the help anyway. Your script was great too. – Fiksdal Mar 31 '16 at 19:32
  • @Fiksdal Aha, I would actually be curious to what he did with the window to hide it :) – Jacob Vlijm Mar 31 '16 at 19:34
  • You can contact him at contact@iristech.co. I'm sure he'll be happy to share the file with you as well, so that you can look at the source code. – Fiksdal Mar 31 '16 at 19:41