Closed jakubgs closed 3 years ago
Okay, I think setting CM_IGNORE_WINDOW=fpass
works, since my urxvt
puts the command running into the window title and that allows clipmenu
to ignore it properly based on X window title:
> xprop | grep WM_NAME
_NET_WM_NAME(UTF8_STRING) = "jakubgs: fpass"
WM_NAME(STRING) = "jakubgs: fpass"
Actually no, it doesn't. I was testing it incorrectly.
Actually, no, it does work, but only when I call fpass
via urxvt
with -name fpass
.
And I just have to properly pass CM_IGNORE_WINDOW
to the user systemd service.
Oh, I see what's happening. I modified the script at: https://github.com/cdown/clipmenu/blob/a3f0897aee7b1ebe590260dc51a46999367c95e9/clipmenud#L160-L163 And added:
echo "windowname: '$windowname'"
And what it shows me is that the window name changes before clipmenud
has the time to check it:
windowname: '~'
New clipboard entry on clipboard selection: "something"
Surprisingly. Just adding this at the end of my fpass
script:
sleep 0
Causes it to see the window name correctly:
windowname: 'jakubgs: fpass'
ignoring clipboard because windowname "jakubgs: fpass" matches ".*fpass"
Which makes no sense to me. But okay.
I'm not sure, but I think that sleep
command uses sleep(0)
system call which causes the current thread to relinquish control of the CPU and allows the clipmenud
process to catch the window name in time.
It's a bit hacky, but works for me.
Hmm, why don't you just use clipctl disable
? :-)
Oh, that's even better. Thanks!
Hmmm, but I'm getting clipmenud is not running
:
> clipctl disable
clipmenud is not running
> clipctl enable
clipmenud is not running
> systemctl --user status clipmenu
● clipmenu.service - Clipboard management daemon
Loaded: loaded (/nix/store/9c31dhdwdak52dc195masrq94ldz7x7v-unit-clipmenu.service/clipmenu.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-03-10 23:10:38 CET; 25s ago
Main PID: 8375 (.clipmenud-wrap)
CGroup: /user.slice/user-1000.slice/user@1000.service/clipmenu.service
├─8375 /nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin/bash /nix/store/grjqwkz5y4lk1sg1ickzba3vacns9gzg-clipmenu-6.1.0/bin/.clip>
└─9363 clipnotify
Mar 10 23:10:38 caspair systemd[4887]: clipmenu.service: Succeeded.
Mar 10 23:10:38 caspair systemd[4887]: Stopped Clipboard management daemon.
Mar 10 23:10:38 caspair systemd[4887]: Started Clipboard management daemon.
Must be something about how I run the user systemd service.
Interesting:
> pgrep -u "$(id -u)" -nf 'clipmenud$'
> pgrep -u "$(id -u)" -nf 'clipmenud'
8375
Oh, it's because of how it's run:
> grep ExecStart /nix/store/9c31dhdwdak52dc195masrq94ldz7x7v-unit-clipmenu.service/clipmenu.service
ExecStart=/nix/store/grjqwkz5y4lk1sg1ickzba3vacns9gzg-clipmenu-6.1.0/bin/clipmenud
> cat /nix/store/grjqwkz5y4lk1sg1ickzba3vacns9gzg-clipmenu-6.1.0/bin/clipmenud
#! /nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin/bash -e
export PATH='/nix/store/si3a71s4jrn8v2llv5kywxhw4pkg32cc-clipnotify-git-2018-02-20/bin:/nix/store/859fmkp1qad7l4qllaxs0j9r5sls7qxn-xsel-unstable-2019-08-21/bin:/nix/store/949i8wzps6c3dn0x949q4pn964z1581y-dmenu-4.9/bin:/nix/store/2mjxf37a3yrbkk5jd7r2gnwmcig5wkr9-util-linux-2.36-bin/bin:/nix/store/b9j6qhmxpwfvga2bfxn1khjrv3v3qxg7-gawk-5.1.0/bin'${PATH:+':'}$PATH
exec -a "$0" "/nix/store/grjqwkz5y4lk1sg1ickzba3vacns9gzg-clipmenu-6.1.0/bin/.clipmenud-wrapped" "$@"
It's because the process is called .clipmenud-wrapped
not clipmenud
. Annoying.
Oh, looks like this was already fixed in nixos-unstable
: https://github.com/NixOS/nixpkgs/commit/2f81c7a7
It just hasn't trickled down into nixos-20.09
. Easy enough fix.
{ pkgs, ... }:
let
unstablePkgs = import <nixos-unstable> { };
in {
# Enable clipboard manager
services.clipmenu = {
enable = true;
package = unstablePkgs.clipmenu;
};
}
And now it works:
> clipctl disable
> clipctl enable
I'm using
xsel
to in my wrapper script forpass
which allows me to search for secrets using FZF.How can I prevent clipmenu from storing passwords I put into clipboard with
xsel
?I tried setting
CM_IGNORE_WINDOW=xsel
but that does nothing.Or is there maybe some other way I can put these secrets into clipboard from a bash script?