Caffeine installed, but will not start

I am running 15.4 on LXQT

I installed Caffeine from the openSuse software search site. here. It is supposed to reside in the system tray, but is not there. It is also not in the menu, nor can it be started via the terminal as user or root.

User terminal errors:

caffeine
Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 key/usr/bin/caffeine:25: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version(‘Gtk’, ‘3.0’) before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gtk, GLib
Traceback (most recent call last):
File “/usr/bin/caffeine”, line 36, in
ewmh = EWMH()
File “/usr/lib/python3.6/site-packages/ewmh.py”, line 50, in init
self.display = _display or display.Display()
File “/usr/lib/python3.6/site-packages/Xlib/display.py”, line 89, in init
self.display = _BaseDisplay(display)
File “/usr/lib/python3.6/site-packages/Xlib/display.py”, line 71, in init
protocol_display.Display.init(self, *args, **keys)
File “/usr/lib/python3.6/site-packages/Xlib/protocol/display.py”, line 166, in init
raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can’t connect to display “:0”: b’Invalid MIT-MAGIC-COOKIE-1 key’

Root (su) terminal errors:

# caffeine
No protocol specified
No protocol specified
/usr/bin/caffeine:25: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version(‘Gtk’, ‘3.0’) before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gtk, GLib
Traceback (most recent call last):
File “/usr/bin/caffeine”, line 36, in
ewmh = EWMH()
File “/usr/lib/python3.6/site-packages/ewmh.py”, line 50, in init
self.display = _display or display.Display()
File “/usr/lib/python3.6/site-packages/Xlib/display.py”, line 89, in init
self.display = _BaseDisplay(display)
File “/usr/lib/python3.6/site-packages/Xlib/display.py”, line 71, in init
protocol_display.Display.init(self, *args, **keys)
File “/usr/lib/python3.6/site-packages/Xlib/protocol/display.py”, line 166, in init
raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can’t connect to display “:0”: b’No protocol specified\n’
# caffeine --version
No protocol specified
No protocol specified
/usr/bin/caffeine:25: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version(‘Gtk’, ‘3.0’) before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gtk, GLib
caffeine 2.8.3
# caffeine --help
No protocol specified
No protocol specified
/usr/bin/caffeine:25: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version(‘Gtk’, ‘3.0’) before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gtk, GLib
usage: caffeine [-h] [-V]

Prevent desktop idleness in full-screen mode

optional arguments:
-h, --help show this help message and exit
-V, --version show program’s version number and exit

Searched existing topics, here which suggested:

Hi, here is solution which helped me:
I run in konsole this patch - “sudo zypper in python-xdg”, and my caffeine running now.

Was able to locate it in the software search here, but I don’t want to screw up my system so am asking the forum if this is safe first.

Thank you for any help available.

Why not simply from the OSS repo with YaST or zypper?

Oh, and please, when you copy/paste from the terminal emulator, the include the prompt/command line and use the </> button, thus NOT the " button from the tool bar of the post editor.

thanks, and yes, the command prompt is in the information above. I made them in bold to stand out. Example below.

# caffeine --help
No protocol specified

I had been searching on the internet, reading when I found Caffeine listed. I was not familiar with it and searched on the software site. It was installed via zypper, btw.
I didn’t realize it was on the normal repos. I have uninstalled the manual installation and reinstalled with YaST.

The error messages are the same as listed above. Still need help, thanks.
Rebooting now.
(thanks for the tip on the </>)

dad@localhost:~> caffeine
Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 key/usr/bin/caffeine:25: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import GObject, Gtk, GLib
Traceback (most recent call last):
  File "/usr/bin/caffeine", line 36, in <module>
    ewmh = EWMH()
  File "/usr/lib/python3.6/site-packages/ewmh.py", line 50, in __init__
    self.display = _display or display.Display()
  File "/usr/lib/python3.6/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python3.6/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/lib/python3.6/site-packages/Xlib/protocol/display.py", line 166, in __init__
    raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Invalid MIT-MAGIC-COOKIE-1 key'

dad@localhost:~> su
Password: 
localhost:/home/dad # caffeine
No protocol specified
No protocol specified                                                                   
/usr/bin/caffeine:25: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.  
  from gi.repository import GObject, Gtk, GLib                                               
Traceback (most recent call last):                                                           
  File "/usr/bin/caffeine", line 36, in <module>                                             
    ewmh = EWMH()                                                                            
  File "/usr/lib/python3.6/site-packages/ewmh.py", line 50, in __init__                      
    self.display = _display or display.Display()
  File "/usr/lib/python3.6/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python3.6/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/lib/python3.6/site-packages/Xlib/protocol/display.py", line 166, in __init__
    raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'No protocol specified\n'

Did you install a community version or the tumbleweed version from there?

You said it was installed by zypper. Does that mean the downloaded package from the link was installed by zypper or did you just run

sudo zypper in caffeine

This one-click-installation might have added the repo the package is coming from… As I have tumbleweed I didn’t try leap packages but at least community packages add the respective repo to your system.

So, as on your link there is no version for Leap available as one-click-install, in case you used it please check and correct (if necessary) your repo list and if you have the non-leap version deinstall caffeine.

You can install it from the official repoistory by using zypper, as hcvv recommended.

I have no idea why you tried that. But the mantra is that you should never run something “as root” when there is no need to do so. And I do not really know this program, but from the dewscription I understand that it is something for a desktop. Thus something for a desktop user and never for root.

And, you are lucky, because it will not do much “as root” because it has no access to the desktop of the end-user.

Also, while we are talking about general good practices in Unix/Linux, please always use

su -

and not plain su. I know that the most dangerous results of doing this are now blocked in the program, but it is still good practice to use su -.

And I am with @404_UsernameNotFound that your action to install this the first time might be done using the so called “one click install”, which mau habve added extra repos and thus broken your repo list. So please first show the list:

zypper lr -d

To me it looks that there is some Python problem (maybe version) and that could be the result of not having caffeine from the correct repo.

@idee:

AFAICS, from YaST and the Leap 15.5 Main Repository, the version of the packet “caffeine” is 2.8.3-bp155.2.11.

(deleted by author) ------

404 & hcvv answering your questions,
I always try to stay within the openSuse “world” as the safest options. 1st level is obviously the standard repos, 2nd is community repos, 3rd others but check and verify before trusting.
For safety I primarily use Yast to install and uninstall, though I have used zypper as needed. I regularly use zypper dup for updates.

I misspelled Caffeine originally when searching via Yast, so it wasn’t found. Then I looked at the openSuse software search, where it was found. The solution for 15.4 was under “experimental packages” GNOME:Apps. as version 2.8.3 , that standard repo was already part of my repo list, so nothing new was added.

I have to do the Expert Download method (Add repository and install manually) because 1 Click Install hasn’t worked for years on my computer for some reason. When selected it only shows a page of text, the 1-click script. It’s no big deal to do it manually, which is zypper commands, so that is what I do, but if anyone knows how to fix that, it would be great.

What was done originally (but has since been uninstalled, and reinstalled via Yast):

For 15.4 run the following as root:

zypper addrepo https://download.opensuse.org/repositories/GNOME:Apps/15.4/GNOME:Apps.repo
zypper refresh
zypper install caffeine

I would still like to get Caffeine running. 404 mentioned likely Python not matching. I don’t want to mess anything up, so what can I do to get more information to the group here, and how do I correct it so Caffeine might work? Or is there another app you would suggest? The goal is to be able to stream without the locker coming on.

hcvv, the python insight was from you. thanks.

Repo list

:~> zypper lr -d
#  | Alias                                        | Name                                                                 | Enabled | GPG Check | Refresh | Priority | Type   | URI                                                                                 | Service
---+----------------------------------------------+----------------------------------------------------------------------+---------+-----------+---------+----------+--------+-------------------------------------------------------------------------------------+--------
 1 | GNOME_Apps                                   | GNOME Applications (15.4)                                            | Yes     | (r ) Yes  | No      |   99     | rpm-md | https://download.opensuse.org/repositories/GNOME:/Apps/15.4/                        | 
 2 | X11_Utilities                                | X11 Utilities (15.4)                                                 | Yes     | (r ) Yes  | No      |   99     | rpm-md | https://download.opensuse.org/repositories/X11:/Utilities/15.4/                     | 
 3 | ftp.gwdg.de-openSUSE_Leap_$releasever        | Packman                                                              | Yes     | (r ) Yes  | Yes     |   85     | rpm-md | http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_15.4/                  | 
 4 | home_AndnoVember_LXQT                        | The Lightweight Qt Desktop Environment (15.4)                        | Yes     | (r ) Yes  | No      |   99     | rpm-md | https://download.opensuse.org/repositories/home:/AndnoVember:/LXQT/15.4/            | 
 5 | home_fstrba                                  | fstrba's Home Project (openSUSE_Factory)                             | No      | ----      | ----    |   99     | rpm-md | https://download.opensuse.org/repositories/home:/fstrba/openSUSE_Factory/           | 
 6 | openSUSE-Leap-15.4-1                         | openSUSE-Leap-15.4-1                                                 | No      | ----      | ----    |   99     | rpm-md | hd:/?device=/dev/disk/by-id/usb-SanDisk_Cruzer_Glide_4C530000040624123013-0:0-part2 | 
 7 | opensuse-guide.org-openSUSE_Leap_$releasever | Libdvdcss Repository                                                 | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://opensuse-guide.org/repo/openSUSE_Leap_15.4/                                  | 
 8 | repo-backports-debug-update                  | Update repository of openSUSE Backports (Debug)                      | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/backports_debug/                      | 
 9 | repo-backports-update                        | Update repository of openSUSE Backports                              | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/backports/                            | 
10 | repo-debug                                   | Debug Repository                                                     | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/debug/distribution/leap/15.4/repo/oss/                 | 
11 | repo-debug-non-oss                           | Debug Repository (Non-OSS)                                           | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/debug/distribution/leap/15.4/repo/non-oss/             | 
12 | repo-debug-update                            | Update Repository (Debug)                                            | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/debug/update/leap/15.4/oss/                            | 
13 | repo-debug-update-non-oss                    | Update Repository (Debug, Non-OSS)                                   | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/debug/update/leap/15.4/non-oss/                        | 
14 | repo-non-oss                                 | Non-OSS Repository                                                   | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.4/repo/non-oss/                   | 
15 | repo-oss                                     | Main Repository                                                      | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.4/repo/oss/                       | 
16 | repo-sle-debug-update                        | Update repository with updates from SUSE Linux Enterprise 15 (Debug) | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/debug/update/leap/15.4/sle/                            | 
17 | repo-sle-update                              | Update repository with updates from SUSE Linux Enterprise 15         | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/sle/                                  | 
18 | repo-source                                  | Source Repository                                                    | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/source/distribution/leap/15.4/repo/oss/                | 
19 | repo-update                                  | Main Update Repository                                               | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/oss                                   | 
20 | repo-update-non-oss                          | Update Repository (Non-Oss)                                          | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/non-oss/

First, don’t use openSUSE software search. It is broken since ages and doesn’t show the actual packages from official repos. Use Yast2 software instead to search in official repos.

The repo number #1 is not an official standard repo. So you need to uninstall caffeine first. After that remove repo #1

Then simply do a “zypper in caffeine” as this package is in the standard OSS repo (your #15).

As caffeine is broken and got no update since 7 years as indicated by dturtisfra above, you need to do some steps to get this app running. The autostart doesn’t work anymore…

So you need to make a shortcut to “/usr/share/applications/caffeine-indicator.desktop” and execute it. This will place an indicator to your taskbar which you can toggle on and of per right-click menu. This will prevent the screensaver starting.

Caffeine still throws some errors if executed from commandline, but not the ones that you have. You seem to have broken your openSUSE installation by adding a home repository #4 for LXQT instead of using LXQT from the OSS repo.

That is NOT correct for Leap.

Out of curiosity - why? Using up instead of dup on Tumbleweed has well known drawbacks. What exactly does not work or works incorrectly using dup on Leap?

It mostly works. I normally use “up” (or “patch”). But I occasionally run zypper dup -D to see what would happen.

A quick test this morning show that it will update exactly the same packages as zypper up.

This OT question is explained in man zypper:

update (up) [options] [packagename]...
Update installed packages with newer versions, where possible.

This command will not update packages which would require change of package vendor unless the vendor is specified in /etc/zypp/vendors.d, or which would require manual resolution of problems with dependencies. Such non-installable updates will then be listed in separate section of the summary as "The following package updates will NOT be installed:".
dist-upgrade (dup) [options]
Perform a distribution upgrade. This command applies the state of (specified) repositories onto the system; upgrades (or even downgrades) installed packages to versions found in repositories, removes packages that are no longer in the repositories and pose a dependency problem for the upgrade, handles package splits and renames, etc.

If no repositories are specified via the --from option, zypper will do a global upgrade with all defined repositories. This global form of dup will also consider unchanged installed packages and re-evaluate their dependencies. This can be a problem if the system contains conflicting repositories, like repositories for two different distribution releases. This often happens if one forgets to remove an older release repository after adding a new one, say openSUSE 13.1 and openSUSE 13.2.

Thanks all.

I uninstalled caffeine and then removed the Gnome Apps repo.
Reinstalled with zypper. Using Yast to verify, it is 2.8.3-bp154.1.30-noarch from vendor openSuse. The other available version is 2.8.3-bp154.1.30-noarch from Main Repository with priority 99 and vendor openSuse.

Tried to launch from terminal, but It still provides the same MIT-MAGIC-COOKIE-1 error as noted above.

~> caffeine
Invalid MIT-MAGIC-COOKIE-1 keyInvalid MIT-MAGIC-COOKIE-1 key/usr/bin/caffeine:25: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import GObject, Gtk, GLib
Traceback (most recent call last):
  File "/usr/bin/caffeine", line 36, in <module>
    ewmh = EWMH()
  File "/usr/lib/python3.6/site-packages/ewmh.py", line 50, in __init__
    self.display = _display or display.Display()
  File "/usr/lib/python3.6/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python3.6/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/lib/python3.6/site-packages/Xlib/protocol/display.py", line 166, in __init__
    raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Invalid MIT-MAGIC-COOKIE-1 key'

I am rebooting


As for updates, trying to understand, and wanting to do this the correct way.
A couple of questions.

1 - If the openSuse software search is broken, why is it still being maintained? We rely on being able to trust openSuSE.org.

2 - The definitions from hui helped. From what I see zypper up, updates only what you have and doesn’t install anything new if there are any dependency changes. (ie, now there are 33 packages not updated).
However zypper dup checks and verifies the dependencies and makes changes if needed to keep the installed system clean. That seems like a good thing to me. Is there more to it that a dup would cause issues?
(and you are correct, when I was using Tumbleweed learned about zypper dup.)

3 - So zypper up -D is checking dependencies similar to dup, but gives manual control verses an automatic change. Is that correct?
Zypper -help defines it as “Use alternative repository definition file directory”

Good question.

After the reboot the symlinks from /usr/share/applications/caffeine.desktop and /usr/share/applications/caffeine-indicator.desktop did not do anything so I tried both in terminal

dad@localhost:~> /usr/share/applications/caffeine.desktop
bash: /usr/share/applications/caffeine.desktop: Permission denied
dad@localhost:~> /usr/share/applications/caffeine-indicator.desktop
bash: /usr/share/applications/caffeine-indicator.desktop: Permission denied

hmmm, doubleclick and execute works on my Leap 15.4 test installation…

You seem to have broken your openSUSE installation by adding a home repository #4 for LXQT instead of using LXQT from the OSS repo.

Those were from a previous app challenge. They were disabled and are not active. LXQT was not installed from there. I just deleted them as repos, ran zypper refresh and then zypper up, which shows 14 packages updates ignored, and also zypper dup -D. Everything is clean. “nothing to do”

Perhaps the python version? It that worth checking?

Or the permissions? in /usr/bin they are root/root
in /usr/share/applications they are also root/root