Controlling the clipboard via Zenity and Xclip

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Shortcuts

You can easily set up helpful keyboard shortcuts to use your clipboard, and then you won't have to remember the parameters or input them by hand.

To do this in Unity, you can look for System Settings under the gear menu (in the upper right-hand corner of your screen), select Keyboard and open the Shortcuts tab.

In Gnome, the process is virtually the same: Go to System settings | Keyboard | Keyboard shortcuts . Do the same in KDE. When using other window managers, you can typically find the appropriate settings under the keyboard entry in the desktop configuration app.

You will then have to enter the path to the script together with one of the following parameters: retrieve , save , delete , or edit . The commands used to create four shortcuts (Figure 1) are shown in Listing 2. After defining the commands, you can fill in the key combination that will trigger the shortcut.

Figure 1: How to set keyboard shortcuts for the script with four different parameters.

Listing 2

Create Keyboard Shortcuts

/home/MyDirectory/clipboard.sh save
/home/MyDirectory/clipboard.sh retrieve
/home/MyDirectory/clipboard.sh delete
/home/MyDirectory/clipboard.sh edit

Conclusion

Now, you have a clipboard (Figure 2) that you can extend and customize as you wish. For example, you could add additional memory locations and have the current date, contact information, or other frequently used content ready to copy and paste wherever you need it. Zenity and Xclip lets you get up and running easily, and the clipboard can be used in most window managers. You only need to create the corresponding keyboard shortcuts.

Figure 2: The clipboard in action: a space filled with the current value of the clipboard.

Infos

  1. Xclip: http://xclip.sourceforge.net
  2. Zenity: http://live.gnome.org/Zenity
  3. "Automating tasks with SSH, Zenity, Yad, KDialog, PuTTY, WinSCP, and Rex Secure Agent" by Tim Schürmann, Linux Magazine , 146: http://www.linux-magazine.com/Issues/2013/146/Script-Dialogs/%28language%29/eng-US

Buy this article as PDF

Express-Checkout as PDF

Pages: 3

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content