8

I often find myself pasting the same strings into the browser (I have a youtube channel, and at the end of the videos I constantly post the same links: channel URL, website, email, introductory video, etc).

I thought about creating a text file and then adding it to the Unity panel, but unfortunately while I see the way to add the text editor to it, I can't add the text file to be opened with the text editor. I could probably put a script together and add that to the panel, but then it struck me that other people probably had the same time wasting experience, and probably have already found the solution.

In the perfect world I need an application that stores commonly needed strings, when loaded it would right away start on top of other windows and stay as such, it would have buttons for different strings, and they would be placed into the buffer as soon as pressed. This way I would just assign that which I need to those buttons and be very very happy.

If no good solution exists, I will just have to create it myself, I guess. After all my channel is about programming, and I can probably make a wonderful lesson just out of creating such a tool.

Suzana
  • 392
v010dya
  • 1,472
  • Are you talking about a clipboard manager coz that's how av understood your scenario - manage multiple pieces of text which can be copied directly to the clipboard and pasted when needed...if so, check out Diodon http://askubuntu.com/a/37980/163331 – Parto Feb 03 '14 at 13:03
  • @AvatarParto Well, i don't understand what you mean by 'clipboard manager', to me 'clipboard manager' is just something that lets you see what is in the buffers right now. It doesn't hold information itself, and doesn't preserve it from day to day. If that is what you mean, then no, this is not what i am talking about. – v010dya Feb 03 '14 at 13:06
  • sooo a sticky notes? :) – Rinzwind Feb 03 '14 at 13:07
  • Actually Diodon does (am using it right now). I can copy like a password which I can access even after I have restarted my machine. All you have to do is increase the history size and it will remember everything you copy cntr+c or just right click->copy. One click to the text you want and you can paste it anywhere. – Parto Feb 03 '14 at 13:09
  • @Rinzwind My favourite sticky note software is xpad, just awesome. sudo apt-get install xpad – Parto Feb 03 '14 at 13:11
  • I would definitely (for security reasons) not want to remember everything i've copied. Sticky note is good, but it would require more than a single button click to copy this text. I would then just go with the text document pushed on the Unity bar. – v010dya Feb 03 '14 at 15:29

3 Answers3

7

You can install autokey with sudo apt-get install autokey-gtk for the GTK+ version or sudo apt-get install autokey-qt for the Qt version.

autokey allows you to define abbreviations which when typed in anywhere in your xsession will expand to a defined phrase: E.g I defined an abbreviation xyy for the phrase Thank you for your help. I ticked in the Always prompt before pasting this phrase option in the autokey configuration. From now on, anywhere I type xyy and hit a space, a small pop-up appears, which I can select with a down-arrow key and an ENTER and the typed xyy is replaced with the phrase Thank you for your help.

If you don't tick in the "prompt before pasting" option then the abbreviation is replaced immediately after you hit space. You can also define scripts, like for inserting the current date.

I use autokey-gtk on 12.04 which has a minor problem that the autokey tray icon doesn't show up on the panel. To correct this just launch dconf-editor and add 'Autokey' to the Desktop->Unity->Panel->systray-whitelist array. E.g. for me it contained ['JavaEmbeddedFrame', 'Wine', 'Update-notifier'] and I modified it to ['JavaEmbeddedFrame', 'Wine', 'Update-notifier', 'Autokey']. If you are using Unity2D then this won't solve the problem because of a bug in Unity2D. For Unity2D you have to change the array to ['all'] to whitelist every app. After these modifications log-out/log-in and the tray icon should be visible now.

Don't forget to set autokey to start up on login, on the Edit->Preferences->General tab.

falconer
  • 15,026
  • 3
  • 48
  • 68
5

Personally I've found ClipIt to cover all my copy/paste needs.

sudo apt-get install clipit

With it's hotkey combinations you can pretty much get to any paste item super quickly. I have set Ctrl+Alt+H to "manage history" which allows me to instantly launch a floating window, type a search for the item I want to paste and paste it directly into whatever window I'm in (make sure "Automatically paste selected item" is checked in Preferences > Settings).

There's also the fast access "Manage hotkey" which shows you a list of the most recent 20 clips for quick access. If the items you're pasting are used commonly they'll be in your history.

If you're not pasting them that commonly you could use ClipIt's "Actions" feature to place items into the clipboard quickly.

For example, in actions you could add:

Action: test
Command: clipit "this is a test line to be pasted"

You can then run the actions hotkey (default ctrl+alt+a), select your command title, and then ctrl+v to paste.

Works pretty sweetly. Sadly I haven't worked out how to make the action auto-paste into the current window. I tried piping to xclip -o but that doesn't work.

alexleonard
  • 173
  • 6
  • It is a good thing that you have posted it, and i do like it, but it is still slightly more key presses than i would like. It does not beat the text file on the Unity bar, that would have an additional benefit of being able to go into the Dropbox and be synced across several machines. – v010dya Feb 06 '14 at 08:22
  • 1
    Hey Volodya - yeah, it would be nice if I could work out a way to | and auto-paste. I didn't realise cross-machine syncing was an issue. Potentially this could be handled by symlinking clipit config into a dropbox folder on each machine - though I haven't tested that! – alexleonard Feb 06 '14 at 09:22
  • 1
    Sorry, i didn't mean to say that cross machine is an issue, i'm just saying that if two things require the same number of key presses, but one has the ability to cross-sync and another doesn't, then i'd go with the one that can. But i do see the point about just connecting the config file to the dropbox. – v010dya Feb 06 '14 at 14:39
  • You can save that extra key press and autopaste the string when you use this command as action: printf "mytextstring\nwith newlines" | clipit && xdotool key ctrl+v . – Suzana Sep 14 '16 at 09:28
  • Well for commands you'll mostly use in the (Unix/Linux) terminal, it would be xdotool key ctrl+shift+v – Suzana Sep 14 '16 at 09:43
3

This can be done by creating a custom launcher for GEdit to open your text file

  1. Install gnome-panel. The package will provides the tool to create launcher:

    sudo apt-get install gnome-panel --no-install-recommends

  2. Create custom launcher with gnome-desktop-item-edit:

    gksudo gnome-desktop-item-edit /usr/share/applications/ --create-new

    2.1. Set launcher type to Applications

    2.2. Give a name for it (eg: Youtube Channel,...)

    2.3. Set the command to gedit <path to text file>

    • The command above will trigger gedit (Text Editor) and open (or create) the spectified file.

    2.4. Give it a comment (optional)

    2.5. Click OK :p

  3. Search the new launcher in Dash

  4. Add it to panel and volia! You've done ;)


UPDATE: If you want click-to-copy then install xsel

sudo apt-get install xsel

  • Then follow the instruction above
  • Change the command in step 2.3 to:

xsel --clipboard -i

And you have click-to-copy launcher (NOTE: there will be no output showing that you have copied the text)

v2r
  • 9,547
leorize
  • 811