Hi,
I share with you a script to copy to the clipboard a card number. The script is completed with a launcher in the menu. For my part, I put a shortcut of launcher on the desktop. Of course, do not use the script to copy a password!
There are two small problems with the script. The first appears to be related to Plasma Kubuntu 15.04. It takes two clicks on the icon to get the copy of CARDNO in the clipboard. The first click starts Klipper, the second click makes the copy. The second problem is related to the last line of code commented out. For whatever reason, klipper is not killed.
Suggestions for improvements are welcome.
Thank you.
Pierre
I share with you a script to copy to the clipboard a card number. The script is completed with a launcher in the menu. For my part, I put a shortcut of launcher on the desktop. Of course, do not use the script to copy a password!
Code:
#!/bin/bash # Copy to clipboard the card No. specified by the CARDNO variable. CARDNO="0123456789" # Launch klipper service if it is not already running. if ! ps ax | grep '[k]lipper' > /dev/null then # Start klipper as a process independent of this process. nohup klipper & fi # Copy to clipboard qdbus org.kde.klipper /klipper setClipboardContents $CARDNO # Kill klipper process to leave only the clipboard service in the taskbar. # cf. http://stackoverflow.com/questions/3510673/find-and-kill-a-process-in-one-line-using-bash-and-regex # for explanation on the Tip of the [x] with grep. #kill $(ps aux | grep '[k]lipper' | awk '{print $2}')
Suggestions for improvements are welcome.
Thank you.
Pierre
Comment