cdown / clipmenu

Clipboard management using dmenu
MIT License
1.14k stars 91 forks source link

keepassxc vs. clipmenu #200

Closed benibilme closed 7 months ago

benibilme commented 1 year ago

Hello,

I am trying out clipmenu. I encountered one problem. I am using keepassxc to manage my passwords. Sometimes, I have to manually copy paste the password. Keepassxc, to the best of knowledge, cleans the clipboard after sometime, but the password is always being recorded by clipmenud.

  1. How can I get rid of recorded password? Where are the clips stored?
  2. Is there any other solution other than clipctl enable/disable to prevent the passwords being recorded.

Thanks in advance

cdown commented 1 year ago

clipmenu doesn't hold the selection unless you have CM_OWN_SELECTIONS=1. Are you running with that? Can you show me the output of /proc/$(pgrep clipmenud)/environ?

benibilme commented 1 year ago

Hello,

I am sorry to respond you late. I have installed clipmenud via arch aur package. It installs a systemd user service. The service file is as follows.

[Unit]
Description=Clipmenu daemon

[Service]
ExecStart=/usr/bin/clipmenud
Restart=always
RestartSec=500ms

MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
ProtectControlGroups=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=
RestrictRealtime=yes

# We don't need to do any clean up, so if something hangs (borked xclip, etc),
# it's going to stay that way. Just forcefully kill and get it over with.
TimeoutStopSec=2

[Install]
WantedBy=default.target

I am using i3wm. I open up menu via following command.

bindsym $mod+c exec CM_LAUNCHER=rofi clipmenu -i -fn Terminus:size=8 -nb '#002b36' -nf '#839496' -sb '#073642' -sf '#93a1a1'

/proc/$(pgrep clipmenud)/environ returned nothing in my system. I am using arch. The service is installed as user service.

systemctl --user status clipmenud
● clipmenud.service - Clipmenu daemon
     Loaded: loaded (/usr/lib/systemd/user/clipmenud.service; enabled; preset: enabled)
     Active: active (running) since Wed 2023-03-15 02:41:10 +03; 1h 24min ago
   Main PID: 7503 (bash)
      Tasks: 2 (limit: 38323)
     Memory: 2.3M
        CPU: 4.568s
     CGroup: /user.slice/user-id.slice/user@id.service/app.slice/clipmenud.service
             ├─ 7503 bash /usr/bin/clipmenud
             └─18492 clipnotify

I did not do any other configuration. I believe I am NOT running with CM_OWN_SELECTIONS=1 unless it is default setting to the best of my knowledge.

However I want clipmenu to record primary selection in addition to secondary as it does now. I just want to understand, is there a way to prevent it not to track passwords from special applications etc without disabling it.

cdown commented 1 year ago

You can also use CM_IGNORE_WINDOW, see clipmenud --help.

benibilme commented 1 year ago

Hello,

I have checked window name with xprop. xprop output is as follows. (I put XX in place of database name)

_NET_WM_USER_TIME(CARDINAL) = 80290238
_NET_WM_STATE(ATOM) =
WM_STATE(WM_STATE):
        window state: Normal
        icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 7
_NET_WM_ICON(CARDINAL) =
_NET_WM_ICON_NAME(UTF8_STRING) =
XdndAware(ATOM) = BITMAP
WM_NAME(STRING) = "xx - KeePassXC"
_NET_WM_NAME(UTF8_STRING) = "xx - KeePassXC"
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x3, 0x3e, 0x7e, 0x0, 0x0
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_XEMBED_INFO(_XEMBED_INFO) = 0x0, 0x1
WM_CLIENT_LEADER(WINDOW): window id # 0x3000008
WM_HINTS(WM_HINTS):
        Client accepts input or input focus: True
        window id # of group leader: 0x3000008
WM_CLIENT_MACHINE(STRING) = "xxxxxx"
_NET_WM_PID(CARDINAL) = 929
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 50331655
WM_CLASS(STRING) = "keepassxc", "KeePassXC"
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_NORMAL_HINTS(WM_SIZE_HINTS):
        user specified location: 2562, 53
        user specified size: 1196 by 1865
        program specified minimum size: 800 by 500
        window gravity: Static

Based on that I have added following directive to systemd unit file under service section

Environment=CM_IGNORE_WINDOW=".*KeePassXC.*"

This is supposed to work based on your input. I have made sure daemons are reloaded. I restarted the service. However clipmenud captures everthing from Keepassxc.

I also would like to point out, that help messages are just very terse. There are no examples. There is no man page. Github page is also has not much information. For example, what type of regular expressions are valid, basic, extended, perl etc. It will be very helpful if you can improve the help messages along with github page.

al23212321 commented 1 year ago

@benibilme Its working for me. I added this line in the shell environment file which in my case is zshenv export CM_IGNORE_WINDOW="KeePassXC"

cdown commented 7 months ago

Closing as this applies to the old bash version, please feel free to resurface if it's a problem in clipmenu 7.