pfr Hmmm nope, this doesn't seem to help. Also, it seems that there is no -sensitive flag for my version of xclip - v0.3

I still think that may be related to how background process on that non-interactive shell are handled by either LXQt or /bin/sh or something else... I sugest you to try trapping SIGHUP:

#!/bin/sh
trap : HUP
rbw-menu password | xclip -selection clipboard

I removed the unneeded set -e line (which exits the shell when something fails). The only command whose exit status is known to shell is xclip (in a pipeline, only the last command's exit status is known), and if XClip fails the shell would exit on error anyway (nothing is run afterwards).

  • pfr replied to this.

    pfr Any more ideas??

    Deja-vu time!

    Try running xclip under nohup like this:

    rbw-menu password | nohup xclip -loop 1 -sel clip >/dev/null
    • pfr replied to this.

      pfr Try without the -loop 1 which was just for security (exit after 1 paste); and before you do a paste, open a terminal, do a ps -Au and check that the xclip process is still around.

      After installing LXQT, I see at least one thing that's wrong, but, it shouldn't be causing your issue:

      LXQT shell quoting seems pretty broken. It works for simple commands, but, if you have chars. like | or $ or anything else exotic it just falls apart.

      Explicitly quoting like this seems to work:

      sh -c '...'

      or, wrapping the cmd. line in a shell-script (like rbw-dmenu).

      What does this rbw-menu look like?

      • pfr replied to this.
      • pfr likes this.

        rvp

        rbw-menu:

        #!/usr/bin/env bash
        set -euo pipefail
        IFS=$'\n\t'
        # Creator: Robert Buchberger <robert@buchberger.cc>
        #                            @robert@spacey.space
        #
        # Select an item from bitwarden with wofi, return value for passed query
        # Dependencies: rbw installed and configured
        #
        # Usage: rbw-menu [query]
        #   query: "code" or anything on the login object; username, password, totp, etc
        #     - code will return a TOTP code
        #     - anything else will return the value of the query
        #   default: username
        
        rbw unlocked &> /dev/null || rbw unlock
        
        query=${1:-username}
        
        chosen_item=$(
            # If RBW_MENU_COMMAND is set, use it to filter the list.
            if declare -p RBW_MENU_COMMAND >&/dev/null; then
                eval "rbw list | $RBW_MENU_COMMAND"
            else # use wofi
                rbw list | wofi --dmenu --matching fuzzy --insensitive --prompt "$query"
            fi
        )
        
        # Exit if user didn't select anything
        declare -p chosen_item >&/dev/null || exit 1
        
        case "$query" in
        code)
            rbw code "$chosen_item"
            ;;
        *)
            # Select chosen item from vault, return login.query
            rbw get "$chosen_item" --raw | jq --join-output ".data.$query"
            ;;
        esac                                                      
        • rvp replied to this.

          pfr OK, can you see if this test script works?

          #!/bin/sh
          set -eu
          ls /bin | dmenu -l 10 | xclip -loop 1 -sel clip
          # ls /bin | $RBW_MENU_COMMAND -l 10 | xclip -loop 1 -sel clip

          Move your rbw-dmenu out of the way; put this in its place. See if selection + paste works. If it does, then uncomment the other line (and comment out the previous one) and try again. Either way should work--it does for me (both running on the command line and via Ctrl-P).

          • pfr replied to this.

            rvp Hmmm the first one works, printing the ls /bin but why exactly is that in the second line?

            Anyway, I wasn't completely honest with my first comment..

            ~ λ ls /bin | $RBW_MENU_COMMAND -l 10 | xclip -loop 1 -sel clip
            error, cannot allocate color ''#c5b3a6''                                                                                                                      
            ~ λ grep RBW .profile                                                                                                                                         
            export RBW_MENU_COMMAND="dmenu -fn CodeNewRomanNerdFont:style=Normal:pixelsize=13:antialias=true -nb '#1f1b18' -nf '#c5b3a6' -sb '#93a1a1' -sf '#000000'"    

            But, we're getting somewhere because the script works from a keybind.

            Well... this is rather embarrassing, but I've solved it.

            I had my key binding set to execute the rbw-menu script... NOT the rbw-dmenu script...
            💀 ⚰️
            Wow.. that's bad, even for me. Sorry for wasting your time.
            I was up at 1am last night doing this so I put it down to lack of sleep 😪

            @pin please delete this entire thread 🙏

            • pin replied to this.
            • Jay likes this.

              pfr @pin please delete this entire thread

              Do you really want me to that?

                pin I think we should keep it so if anyone having same issue will check it also 😅

                “Only the paranoid survive.”

                ― Harold Finch
                NetBSD VPS , NetBSD , OS108

                • pfr replied to this.

                  pin Do you really want me to that?

                  I mean.. It's clear now that there was never an issue to solve in the first place, only stupidity and carelessness, and this thread was a total waste of everyone's time... 😮‍💨

                  Jay I think we should keep it so if anyone having same issue will check it also 😅

                  Feel free to keep it up for amusement, but I highly doubt anyone will have the same issue. But it is a good reminder to have some (any) kind of naming convention for your scripts that wont get you into this mess. Also, just go to bed before midnight!

                  • Jay likes this.

                  FML...

                  You're not going to believe this.

                  The same script wont launch at all from keybinding under sdorfehs on OpenBSD. 😫

                  So, here we go again.

                  The script is the same:

                  #!/bin/sh
                  rbw-menu password | xclip -loop 1 -sel clip

                  the rbw-menu script is the same as above also...

                  The script runs from the command line.

                  These are my keybindings:

                  # scripts
                  definekey top s-t exec $HOME/.scripts/bartoggle.sh
                  definekey top s-d exec $HOME/.scripts/dmenu_run.sh
                  definekey top s-p exec $HOME/.scripts/rbw-dmenu.sh             # <<<< correct script!!! 
                  definekey top s-s exec $HOME/.scripts/dmenu_scrot.sh
                  definekey top s-r exec $HOME/.scripts/ocr.sh
                  definekey top s-c exec $HOME/.scripts/colorpicker.sh

                  Just to further prove it:

                  ~ $ ls .scripts | grep rbw
                  .rwxr-xr-x   66 dave 16 Sep 14:36 rbw-dmenu.sh

                  Thankfully, sdorfehs outputs some info in it's bar when a scripts runs/fails..
                  The output in the bar is:

                  /bin/sh/ -c "$HOME/.scripts/rbw-dmenu.sh" finished (127)

                  Not very helpful.
                  All my other scripts work with their keybindings. This time it's not an issue with xclip, but rather that the script isn't running... Needless to say, I'm now a little confused.. 😕

                  • rvp replied to this.

                    pfr The output in the bar is:

                    /bin/sh/ -c "$HOME/.scripts/rbw-dmenu.sh" finished (127)

                    An exit status of 127 means "command not found". That refers to xclip in that rbw-dmenu.sh script (ie. the last command in a pipeline).
                    Is xclip installed and in your $PATH?
                    Check ~/.xsession (if running xenodm) and ~/.profile if not.

                    Check the error messages on the console or ~/.xsession-errors

                    This worked for me just now:

                    # pkg_add sdorfehs dmenu xclip
                    [...]
                    
                    $ sdorfehs -h
                    sdorfehs 1.5
                    [...]
                    
                    $ dmenu -v
                    dmenu-5.2
                    
                    $ xclip -version
                    xclip version 0.13
                    [...]
                    
                    $ cat ~/.config/sdorfehs/config
                    definekey top F1 exec $HOME/tmp/foo.sh
                    
                    $ cat ~/tmp/foo.sh
                    #!/bin/sh
                    set -eu
                    ls /bin | dmenu -l 10 | xclip -r -loop 1 -sel clip
                    
                    $
                    • pfr replied to this.

                      But as I said, the script runs from the command line so it can't be an issue with xclip. But let me check....

                      rvp

                      ~ $ which xclip
                      /usr/local/bin/xclip
                      
                      ~ $ grep PATH .profile
                      PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:$HOME/.cargo/bin:$HOME/.local/bin
                      export PATH HOME TERM
                      
                      ~ $ cat .xsession-errors
                      sh: /home/dave/.scipts/rbw-dmenu.sh: not found
                      
                      ~ $ cat .xsession
                      # use UTF-8 everywhere
                      export LANG=en_US.UTF-8
                      
                      # specify location of kshrc
                      export ENV=$HOME/.kshrc
                      
                      # load Xresources file
                      xrdb -merge $HOME/.Xresources
                      
                      # picom
                      picom &
                      
                      # disable system beep
                      xset b off
                      
                      # start window manager
                      exec sdorfehs

                      I do use xenomd however I haven't set my path in .xsession. seems to work from .profile (for literally everything else).

                      I did also try to put the script in my path but it still failed to execute

                      • rvp replied to this.

                        pfr But as I said, the script runs from the command line so it can't be an issue with xclip.

                        PATHs set in .profile don't effect progs. started in xenodm. For xdm/xenodm the PATH used is set in either a) the XDM config. file or b) ~/.xsession. (And, since I'm not sitting in front of your computer, I've no way of knowing, from what you've shown so far, where your xclip is--you could've compiled it on your own and put it anywhere...)

                        ~ $ cat .xsession-errors
                        sh: /home/dave/.scipts/rbw-dmenu.sh: not found

                        Notice the typo there. (And, this path isn't what you showed me in post #18)

                        pfr I do use xenomd however I haven't set my path in .xsession. seems to work from .profile (for literally everything else).

                        Doesn't matter in this case as xclip is in both PATHs (xenodm default and .profile--which are usually different; see xenodm).

                        Fix that typo, mate.

                        • pfr replied to this.
                        • Jay likes this.

                          rvp ok, yes that was a typo. However I now get:

                          ~ $ cat .xsession-errors
                          sh: /home/dave/.scripts/rbw-dmenu.sh[2]: rbw-menu: not found

                          So at least I can see now that it can't find rbw-menu
                          But...

                          ~ $ which rbw-menu
                          /home/dave/.local/bin/rbw-menu

                          And, I've certainly got that in my PATH

                          ~ $ grep .local/bin .profile
                          PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:$HOME/.cargo/bin:$HOME/.local/bin

                          It certainly does seem like it's a PATH setting issue. Because even if I move rbw-menu into /usr/local/bin/ it then complains that it can't find /home/dave.cargo/bin/rbw

                          So I've set my PATH in .xsession and you already know that it works.. 😅