-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve exit code from launcher #150
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change is related to cdown#57 (comment). If `clipmenu` "preserves" the exit code from the launcher (exits with the same code as the launcher), the exit code's from Rofi's custom keybindings can be used with `clipmenu`. For example, I'm using the following script bound to `Super+v`: ``` #!/bin/bash trap "exit" INT # Run clipmenu CM_LAUNCHER=rofi clipmenu -p "Paste" -mesg "Use Shift+Delete to delete an item" \ -kb-delete-entry "" -kb-custom-1 "Shift+Delete" \ -kb-accept-alt "" -kb-custom-2 "Shift+Return" exit_code=$? case $exit_code in 0) xdotool key "shift+Insert" ;; 10) clipdel -d ^"$(xsel -b)"$; "$0" ;; *) exit $exit_code ;; esac ``` With the above script, I have 3 different options when running `clipmenu`: - if I press `Return`, the selected item is pasted to where my cursor currently is (a bit hackily with `xdotool`) - if I press `Shift+Return`, the selected item is sent to the clipboard ("default" `clipmenu` behavior) - if I press `Shift+Delete`, the selected item is deleted from `clipmenu`, and the script runs itself again (essentially keeps `clipmenu` open) In order for this to work, the only change needed in `clipmenu` is to preserve the exit codes from the custom keybindings.
cdown
requested changes
Dec 18, 2020
Looks good, thanks! Just a couple of nits. |
@cdown, the requested changes as they are could lead to an error ( |
Only set `$launcher_exit` if not running rofi-script, and only exit using `$launcher_exit` if it has been set. Otherwise, the last line (now with quoting around the variable) becomes `exit ""`, which causes an error.
@cdown, I've implemented the suggested changes, and added a check so that the launcher exit code is used only if the variable is set. |
cdown
reviewed
Dec 19, 2020
Looks good, thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change is related to #57 (comment).
If
clipmenu
"preserves" the exit code from the launcher (exits with the same code as the launcher), the exit codes from Rofi's custom keybindings can be used withclipmenu
.For example, I'm using the following script bound to
Super+v
:With the above script, I have 3 different options when running
clipmenu
:Return
, the selected item is pasted to where my cursor currently is (a bit hackily withxdotool
)Shift+Return
, the selected item is sent to the clipboard ("default"clipmenu
behavior)Shift+Delete
, the selected item is deleted fromclipmenu
, and the script runs itself again (essentially keepsclipmenu
open)In order for this to work, the only change needed in
clipmenu
is to preserve the exit codes from the custom keybindings.