LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-28-2010, 12:43 PM   #1
jakev383
QmailToaster Developer
 
Registered: Dec 2005
Location: Burlington, NC
Distribution: CentOS, Voyage, Debian, Fedora
Posts: 220

Rep: Reputation: 31
Something like Shortkeys


I'm looking for a program that will provide similar functions as Shortkeys for Windows. I installed Shortkeys under Wine, but it does not seem to trigger when I enter the hotkeys.

For those that are not familiar, Shortkeys allows you to enter an abbreviated "short cut" as a trigger and the program will then dump predefined text out.

For example, I routinely send an email to people I work with (the same text every time), and in Windows I just enter !b and Shortkeys will replace the text with the email template (~20 lines or so of instructions).

Ideally I need this to work in Firefox and GEdit.

Any suggestions are appreciated.
Thanks!
 
Old 12-29-2010, 03:32 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947
Install xclip and xdotool packages for your distribution.

Since this is a complex command, and we do not know which shell (if any) is used when executing Application shortcuts, write a simple shell script. Say, ~/bin/xpastefile:
Code:
#!/bin/sh
cat "$@" 2>/dev/null | xclip -selection primary -in && xdotool click 2
The script copies the text in the specified files into the "primary" clipboard, then pastes it via simulating a middle mouse button click -- so you need to have your mouse pointer hovering where you need the text to be pasted at; blinking text cursor position is irrelevant. Since normal copied text uses the "clipboard" clipboard, this does not destroy that.

The script assumes you use the standard mouse button binding, where the middle button pastes the primary clipboard. If you have an active text selection, it is deselected, since selections are tied to the "primary" clipboard in X11. You can modify the script to use the other clipboard, or even type the text directly using xdotool type ..., but I've found those to be slower or less compatible.

You can safely allow everybody to read and execute the script; X11 will take care of the access permissions:
Code:
chmod a+rx ~/bin/xpastefile
Finally, add keyboard shortcuts to
Code:
/home/myself/bin/xpastefile /home/myself/my-templates/template-file.txt
using absolute paths (for the same reason you're using a script file; you can run echo ~/bin/xpastefile ~/my-templates/template-file.txt in a shell to find out the absolute paths). Most desktop environments have a Keyboard control panel with Application shortcuts. If not, you can use xmodmap to set up the mapping in your X profile.

I've only tested this on XFCE, but since these are plain X11 utilities, they should work in all desktop environments.
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 01:35 AM.
 
Old 12-31-2010, 08:24 AM   #3
jakev383
QmailToaster Developer
 
Registered: Dec 2005
Location: Burlington, NC
Distribution: CentOS, Voyage, Debian, Fedora
Posts: 220

Original Poster
Rep: Reputation: 31
That was very in-depth. Thanks! I'll give this a try out over the weekend.
 
Old 01-01-2011, 08:56 AM   #4
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947
You're welcome.

There are also a large number of clipboard managers, which can be used for the same purpose, but with a bit different approach.

For example, xfce4-clipman (which works on other desktop environments with a notification area, only requiring three xfce4 libraries to be installed) has a menu-driven system you can extend yourself: You define a regular expression pattern, and one or more actions. When you select or copy text matching the pattern, clipman pops up a list of the defined actions. The actions can even refer to the original pattern.

Here's how clipman might work for you. First, save your e-mail message templates into files. Then, create new clipman actions. The trigger pattern could be for example your preferred e-mail greeting, say "[Hh]ello,". For each template, add command xclip -selection clipboard -in some-template.txt. Whenever you select text matching the trigger pattern, the clipman menu with all related actions will pop up.
To use these, you would first type the greeting ("Hello," or "hello,") and select it. The clipman menu will pop up, and you can select which template you want. The command is run, and your desired template will be on the clipboard clipboard, so you can paste (ctrl+v) it.

It depends completely on your workflow and habits whether or not clipman is suitable for your needs. Many users might prefer having a menu-driven system, triggered by simply selecting certain text -- which can even be part of the UI, the user does not need to type it themselves. It is much easier to remember the text to select than a keyboard shortcut, especially if there are more than a few to remember. In corporate environments clipman would be much easier to maintain, too; no keyboard shortcuts to remember or track, and the configuration file (xfce4-clipman-actions.xml I believe) is pure XML.

It is a wonder how efficient and user-friendly workflows you can devise in Linux, if you're willing to re-think old (especially MS-derived ) habits.
Nominal Animal

Last edited by Nominal Animal; 03-21-2011 at 01:36 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration