Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: HowTo: Use the unity launcher quicklist for snippets

  1. #1
    Join Date
    Oct 2008
    Beans
    3,509

    HowTo: Use the unity launcher quicklist for snippets

    UPDATE version 1.3 (4-Nov-2013)
    Thank you to Vaphell for doing a rewrite of my script.
    Renamed quicksnips. See included ReadMe.txt for installation and info.
    -------------------------------------------------------------------------------------------


    I find glipper's snippet plugin handy but also quite buggy.

    This will create a launcher with whatever snippets are defined in snippets.txt.
    Just move the extracted .quicksnips folder to your home directory. (folder will be hidden when first extracted)

    Make the scripts executable...
    Code:
    chmod +x ~/.quicksnips/date.sh ~/.quicksnips/quicksnips.sh ~/.quicksnips/snip2clip.sh
    Run the quicksnips.sh script to create/update the launcher.
    Code:
    cd ~/.quicksnips && ./quicksnips.sh
    Open the dash and search for "quicksnips" and drag and drop to the launcher
    or
    open the file browser and and drag and drop ~/.local/share/applications/quicksnips.desktop.

    All you need to do now is create your own snippets as shown in the attached video or
    follow the included ReadMe.txt.
    You can also add snippets from the clipboard content using a quicklist item.
    Adds the snippet and reloads the launcher.

    Snippets are currently sent to "-selection clipboard" (right mouse copy/paste and ctrl+c/ctrl+v).
    See ReadMe.txt to change to "-selection primary" (left mouse selection/middle click paste)

    Requires xclip.
    Code:
    sudo apt-get install xclip
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by stinkeye; November 4th, 2013 at 04:04 AM.

  2. #2
    Join Date
    Aug 2013
    Beans
    11

    Re: HowTo: Use the unity launcher quicklist for snippets

    thanks very much for this -- I have been using xclip in Midnight Commander to similar purpose.


    unfortunately it does not work for me. all the items in snippets.txt display quite handsomely, but no matter which one I select, the clipboard buffer contents do not change. I use Diodon (something like Glipper, I guess) and sometimes things which don't make it to the buffer show up there, but this is not the case.


    should mention 1) I don't know if it's pertinent, but I have the mouse buttons reversed, 2) I have noticed in the past that xclip can be very, very picky/flaky/buggy.

  3. #3
    Join Date
    Feb 2010
    Location
    SR11 Cockpit
    Beans
    Hidden!

    Re: HowTo: Use the unity launcher quicklist for snippets

    Nice stuff stinkeye!

    You'll be famous soon, can I get your autograph now?

  4. #4
    Join Date
    Oct 2008
    Beans
    3,509

    Re: HowTo: Use the unity launcher quicklist for snippets

    Hi ray_field2,
    (See edit in first post)
    Firstly, I made a small change to the xclip.sh file.
    (This isn't related to your problem but may as well change)
    To save dowloading again,make this edit..
    Code:
    gedit ~/.snippets-launcher/xclip.sh
    and change...
    Code:
    echo $1 | tr -d '\n' | xclip
    to
    Code:
    echo "$1" | tr -d '\n' | xclip
    Save the file and close.

    Check the scripts are executable ....
    Code:
    chmod +x ~/.snippets-launcher/date.sh ~/.snippets-launcher/snippets.sh ~/.snippets-launcher/xclip.sh
    It works here with diodon in fact you don't even need a clipboard manager running for it to work.
    The xclip.sh script is whats's run when you click on a snippet in the quicklist.

    Run the command....
    Code:
    ~/.snippets-launcher/xclip.sh 'test snippet works'
    If "test snippet works" shows with a middle click paste then the xclip script is working.

    If not, try sending to the ctrl+c/v of the clipboard.(right click copy/paste)
    Use diodons menu item "clear" in between tests
    Code:
    echo "test snippet works" | tr -d '\n' | xclip -selection clipboard
    Try also -selection primary (should send to middle click same as with no option)

    Let me no the results and we'll go from there.
    Last edited by stinkeye; November 1st, 2013 at 11:04 AM.

  5. #5
    Join Date
    Nov 2013
    Beans
    1

    Re: HowTo: Use the unity launcher quicklist for snippets

    Hello, looks like this doesn't work for snippets with inverted comma ( ' ) in it. So "doesn't" doesn't work

  6. #6
    Join Date
    Oct 2008
    Beans
    3,509

    Re: HowTo: Use the unity launcher quicklist for snippets

    Quote Originally Posted by psypher246 View Post
    Hello, looks like this doesn't work for snippets with inverted comma ( ' ) in it. So "doesn't" doesn't work
    Hi
    Yes, you'll find some copying with quotes in it won't work because of the way it's written to work with
    quicklists. That's just how it is at the moment until I find a better way.
    Thanks.
    Last edited by stinkeye; November 1st, 2013 at 01:50 PM.

  7. #7
    Join Date
    Aug 2013
    Beans
    11

    Re: HowTo: Use the unity launcher quicklist for snippets

    Quote Originally Posted by stinkeye View Post
    Hi ray_field2,
    (See edit in first post)
    Firstly, I made a small change to the xclip.sh file.
    (This isn't related to your problem but may as well change)
    To save dowloading again,make this edit..
    Code:
    gedit ~/.snippets-launcher/xclip.sh
    and change...
    Code:
    echo $1 | tr -d '\n' | xclip
    to
    Code:
    echo "$1" | tr -d '\n' | xclip
    Save the file and close.

    Check the scripts are executable ....
    Code:
    chmod +x ~/.snippets-launcher/date.sh ~/.snippets-launcher/snippets.sh ~/.snippets-launcher/xclip.sh
    It works here with diodon in fact you don't even need a clipboard manager running for it to work.
    The xclip.sh script is whats's run when you click on a snippet in the quicklist.

    Run the command....
    Code:
    ~/.snippets-launcher/xclip.sh 'test snippet works'
    If "test snippet works" shows with a middle click paste then the xclip script is working.

    If not, try sending to the ctrl+c/v of the clipboard.(right click copy/paste)
    Use diodons menu item "clear" in between tests
    Code:
    echo "test snippet works" | tr -d '\n' | xclip -selection clipboard
    Try also -selection primary (should send to middle click same as with no option)

    Let me no the results and we'll go from there.
    I had chmod'd the scripts, so I'm sure that wasn't the problem; I made the change you suggested.

    so now, okay -- 99% of the time I use Ctrl-V to paste, and when I don't, I use [mouse button]/menu, then select paste -- I very seldom use the middle mouse button. it may very well be that it was working before -- so for now, you might want to indicate in the documentation that that's how it's working. I've been too lazy to understand how the X clipboard works, just seem to know that "xclip -i selection clipboard" seems to put it where I want it to.

    anyway for the moment I can middle click on my desktop, just not sure how this is going to work on my netbook...

    thanks

  8. #8
    Join Date
    Oct 2008
    Beans
    3,509

    Re: HowTo: Use the unity launcher quicklist for snippets

    I made a few changes and uploaded a new version.
    Seems to copy and paste everything fine now including long commands.
    Thanks.
    Last edited by stinkeye; November 1st, 2013 at 07:00 PM.

  9. #9
    Join Date
    Aug 2013
    Beans
    11

    Re: HowTo: Use the unity launcher quicklist for snippets

    thanks for the quick response. not quite there yet. I cleaned out the directory, copied in the new files, and chmoded. out of the box, middle-mousebutton pressing shows the clipboard hasn't flushed/copied -- however, the xclip.sh works.

    just for grins, I uncommented the Ctrl-V option and commented out the button-paste. still no joy -- however, once again, xclip.sh works, placing the text where it should be in the buffer where Ctrl-V can paste it.

    tested it on my laptop with same results.

    -ray

  10. #10
    Join Date
    Oct 2008
    Beans
    3,509

    Re: HowTo: Use the unity launcher quicklist for snippets

    In version 1.1 the xclip.sh script isn't used.
    This was giving me problems with quotes and variables.

    Open ~/.snippets-launcher/snippets.sh and go to line #56.
    Change the line...
    Code:
    Exec=sh -c \"head -$n ~/.snippets-launcher/snippets.txt | tail -1 | tr -d '\n' | xclip -i\"
    to
    Code:
    Exec=sh -c \"head -$n ~/.snippets-launcher/snippets.txt | tail -1 | tr -d '\n' | xclip -i -selection clipboard\"
    Update the launcher after change.

    xclip............................................. .default left mouse selection/middle click paste
    xclip -selection primary........................same as above
    xclip -selection clipboard ......................right mouse copy/paste and ctrl+c/ctrl+v

    You can check the commands being run by looking at the ~/.local/share/applications/snippets.desktop file.
    Code:
    gedit  ~/.local/share/applications/snippets.desktop
    You should see similar to this with your snippets listed.
    Code:
    [Desktop Entry]
    Version=1.0
    Name=Snippets
    Comment=Snippets to clipboard using xclip
    GenericName=Snippets
    Exec=gedit /home/glen/.snippets-launcher/snippets.txt
    Icon=/home/glen/.snippets-launcher/Snippets.png
    Terminal=false
    X-MultipleArgs=false
    Type=Application
    Categories=GNOME;System;
    X-Ayatana-Desktop-Shortcuts=Snippet1;Snippet2;Snippet3;Snippet4;Snippet5;Snippet6;Snippet96;Snippet97;Snippet98;Snippet99
    [Snippet1 Shortcut Group]
    	Name=compizconfig-settings-manager
    	Exec=sh -c "head -1 ~/.snippets-launcher/snippets.txt | tail -1 | tr -d '\n' | xclip -i -selection clipboard"
    	TargetEnvironment=Unity
    [Snippet2 Shortcut Group]
    	Name=read -n 1 -p "Press any key to exit this script..." 
    	Exec=sh -c "head -2 ~/.snippets-launcher/snippets.txt | tail -1 | tr -d '\n' | xclip -i -selection clipboard"
    	TargetEnvironment=Unity
    [Snippet3 Shortcut Group].......
    .....................................
    This is the command that runs when clicking on a quicklist item..
    eg if I run the "Exec=" command in the terminal for my first snippet...
    Code:
    sh -c "head -1 ~/.snippets-launcher/snippets.txt | tail -1 | tr -d '\n' | xclip -i -selection clipboard"
    ....it will send compizconfig-settings-manager to right mouse copy/paste and ctrl+c/ctrl+v.

    This is my diodon settings....
    Attached Images Attached Images
    Last edited by stinkeye; November 2nd, 2013 at 04:40 AM.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •