From 4f1d2900d5695185de65c5826b8b18007dffef0b Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Thu, 13 Aug 2015 18:41:07 +0200 Subject: [PATCH] added clipboard setting --- config.example | 4 ++++ rofi-pass | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/config.example b/config.example index 032f3c9..96d8c92 100644 --- a/config.example +++ b/config.example @@ -24,6 +24,10 @@ BROWSER='chromium' help_color='#0C73C2' auto_enter='false' +# Clipboard settings +# Possible options: primary, clipboard, both +clip=primary + # Custom Keybindings autotype="Alt+1" type_user="Alt+2" diff --git a/rofi-pass b/rofi-pass index 8835354..a7fcb42 100755 --- a/rofi-pass +++ b/rofi-pass @@ -54,6 +54,18 @@ xdotool_type() { done } +doClip () { + if [[ $clip == "primary" ]]; then + xclip + elif [[ $clip == "clipboard" ]]; then + xclip -selection clipboard + elif [[ $clip == "both" ]]; then + xclip + xclip -o | xclip -selection clipboard + fi +} + + # main Menu mainMenu () { HELP="${autotype}: Autotype | ${type_user}: Type User | ${type_pass}: Type Password @@ -90,13 +102,12 @@ ${open_url}: Open URL | ${copy_name}: Copy Username | ${copy_pass}: Copy Passwor echo -n "${password}" | xdotool type --clearmodifiers --file - exit elif [[ $rofi_exit -eq 14 ]]; then - echo -n "${stuff[${USERNAME_field}]}" | xclip + echo -n "${stuff[${USERNAME_field}]}" | doClip exit elif [[ $rofi_exit -eq 16 ]]; then showEntry "${selected_password}" elif [[ $rofi_exit -eq 15 ]]; then - echo -n "$password" | xclip - xclip -o | xclip -selection clipboard + echo -n "$password" | doClip notify-send "rofi-pass" "Copied Password\nClearing in 45 seconds" $(sleep 45; echo -n "" | xclip; echo "" | xclip -selection clipboard | notify-send "rofi-pass" "Clipboard cleared") & exit @@ -186,9 +197,9 @@ showEntry () { echo "not doing anything" else if [[ -z $(echo -n "${stuff[${word}]}") ]]; then - echo -n "$word" | xclip + echo -n "$word" | doClip else - echo -n "${stuff[${word}]}" | xclip + echo -n "${stuff[${word}]}" | doClip fi fi elif [[ ${rofi_exit} -eq 10 ]]; then