A problem with regard controlling programs using environmental variable

I have not dealt much with env variables. Recently I am starting to use some application that use them instead of config files to get input from the user. As an example there is a program for managing clipboard history named ‘clipmanu’. Its deamond called clipmenud uses $CM_SELECTION to get which clipboards to use. I have tried to set a value for it and put it in my bashrc, but got no results. Does anyone knows how I should set this up? I am on EOS and suing XFCE. The dev thinks there is an issue on packaging or something , but I guess maybe I am doing something wrong.

Here is the link to issue I created there.

1 Like

Start clipmenud, then run clipmenu to select something to put on the clipboard. For systemd users, a user service called clipmenud is packaged as part of the project.

https://github.com/cdown/clipmenu#clipmenud

The user instance of systemd does not inherit any of the environment variables set in places like .bashrc etc.

:eye: https://wiki.archlinux.org/title/Systemd/User#Environment_variables

Can you elaborate a bit more. The new thing I learnt from your comment was that adding it to .bashrc doesn’t work on systemd. But how I should give another value to clipmenud. I starts on system boot so I should give it somewhere before that. I have a script that I had set to executes and it works for the most part but not this one.

In the link I posted above there are several suggestions for how to set environmental variables for systemd user services.

Please read through that.

I would try the method in the first point:

For users with a $HOME directory, create a .conf file in the ~/.config/environment.d/ directory with lines of the form NAME=VAL. Affects only that user’s user unit. See environment.d(5) for more information.

I see, thank you very much

After setting the variable, you would need to enable and start clipmenud with –user flag:

systemctl --user enable --now clipmenud

It is not working, I think I named the file wrongly. It says this in the link:

Example 1. Setup environment to allow access to a program installed in /opt/foo

/etc/environment.d/60-foo.conf:

but what is this number in start of the filename. I have created a file on ~/.config/environment.d/.conf and put my value in it but nothing happens after restarting system.d . I guess I should not use .conf as the filename but don’t know what to use from the example.

What is this number at the start of the name??!!

I would create a file called clipmenud.conf in .config/environment.d with the desired variable and its value according to the pattern: NAME=VALUE.

Next, I would enable and start clipmenud:

systemctl --user enable --now clipmenud

If the command above won’t work, post the output here.

Also post the content of clipmenud.conf.

1 Like

Nothing happens
Path: ~/.config/environment.d/clipmenud.conf

content:

CM_SELECTIONS="clipboard"

The clipmenu documentation. I am trying to stop clipmenu from copying primary selection into its history file.


clipmenud collects and caches what’s on the clipboard. You can manage its
operation with clipctl.

Environment variables:

  • $CM_DEBUG: turn on debugging output (default: 0)
  • $CM_DIR: specify the base directory to store the cache dir in (default: $XDG_RUNTIME_DIR, $TMPDIR, or /tmp)
  • $CM_MAX_CLIPS: soft maximum number of clips to store, 0 for inf. At $CM_MAX_CLIPS + 10, the number of clips is reduced to $CM_MAX_CLIPS (default: 1000)
  • $CM_ONESHOT: run once immediately, do not loop (default: 0)
  • $CM_OWN_CLIPBOARD: take ownership of the clipboard. Note: this may cause missed copies if some other application also handles the clipboard directly (default: 0)
  • $CM_SELECTIONS: space separated list of the selections to manage (default: “clipboard primary”)
  • $CM_IGNORE_WINDOW: disable recording the clipboard in windows where the windowname matches the given regex (e.g. a password manager), do not ignore any windows if unset or empty (default: unset)

What do you get when you run this command?

systemctl --user status clipmnud

Unit clipmnud.service could not be found.

PS: You had a typo in it . When I correct the clipmenu spelling it gives me this:


     Loaded: loaded (/usr/lib/systemd/user/clipmenud.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Fri 2023-07-07 11:45:30 +0330; 36min ago
   Duration: 23ms
    Process: 84231 ExecStart=/usr/bin/clipmenud (code=exited, status=2)
   Main PID: 84231 (code=exited, status=2)
        CPU: 23ms

Jul 07 11:45:30 lenovo-i315 systemd[1034]: clipmenud.service: Scheduled restart job, restart counter is at 5.
Jul 07 11:45:30 lenovo-i315 systemd[1034]: Stopped Clipmenu daemon.
Jul 07 11:45:30 lenovo-i315 systemd[1034]: clipmenud.service: Start request repeated too quickly.
Jul 07 11:45:30 lenovo-i315 systemd[1034]: clipmenud.service: Failed with result 'exit-code'.
Jul 07 11:45:30 lenovo-i315 systemd[1034]: Failed to start Clipmenu daemon.

Sorry about that.

Reboot your system and see if that makes any difference.

If it is still not working, I am afraid i have no more ideas.

After rebooting it works now , thank you very much for your help.

Do you know how can I set up basic env variables? Like for example $EDITOR and $BROWSER too? I had in the past have a difficult time setting these up in bashrc and make them work consistently all over the system.

1 Like

Glad you got it working!

Please mark the post which gave the solution as such. This will hopefully help other users with similar issue to find the solution more easily.

If you don’t mind, I would refer you to ArchWiki for this.

Also in Xfce there should be some settings where you could set the default applications.

1 Like

Yeah I have the setup for default application in mimetype config file. But setting it up this way has advantages when scripting in terminal.

It depends on what you mean by this.

Since this specific topic is already solved, and your other question is irrelevant, you may want to start a new topic, so you get advice about your new difficulty. :wink:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.