Results 1 to 7 of 7

Thread: I need to create a launcher that will copy a text to the clipboar

  1. #1
    Join Date
    Mar 2011
    Beans
    17

    I need to create a launcher that will copy a text to the clipboar

    hello,
    i've been looking around on how to copy a text to the clipboard from the terminal.
    i found many solutions using the xclip and xsell.

    for example if i use any of the following it will always copy "string" to the clipboard.

    echo string| xclip -i -selection clipboard
    echo string | xsel -i -b
    echo "string" | xsel -b

    the problem is when i want to add it to a launcher to the panel..
    im using ubuntu 10.10, i create a new launcher and i put one of the line above as the command. but it just doesn't work!

    can someone please tell me what am i doing wrong.

    i tried doing the same thing before.
    i created a launcher to put the volume to the max ( 150% )
    all i did was create a launcher and put this line as the command:

    pacmd set-sink-volume 0 100000

    and it works just fine.


    i hope i was clear enough.
    I really appreciate your help. thanks in advance.

  2. #2
    Join Date
    Oct 2008
    Location
    Ottawa, Canada
    Beans
    807
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: I need to create a launcher that will copy a text to the clipboar

    You can't use shell operators like the pipe | in a launcher without some extra care.
    This command should work:
    Code:
    bash -c "echo string | xsel -i -b"
    Cheers!
    Last edited by LewisTM; September 26th, 2012 at 03:17 AM.
    husband@wife$ make sandwich
    Permission denied
    husband@wife$ sudo make sandwich

  3. #3
    Join Date
    Mar 2011
    Beans
    17

    Wink Re: I need to create a launcher that will copy a text to the clipboar

    thanks a lot for the answer..
    it works just fine now !

  4. #4
    Join Date
    Mar 2011
    Beans
    17

    Re: I need to create a launcher that will copy a text to the clipboar

    only problem about the solutions. almost all of them, is that when you past the string from the clipboard it will paste it with a space (or a new line) in front of it. i couldn't find any code that would copy the string without the space.

  5. #5
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: I need to create a launcher that will copy a text to the clipboar

    echo by default adds newline at the end, use echo -n or printf
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  6. #6
    Join Date
    Mar 2011
    Beans
    17

    Re: I need to create a launcher that will copy a text to the clipboar

    i've already used

    echo -n string | xclip -i -selection clipboard .

    and it worked fine without the space.

    problem solved

  7. #7
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: I need to create a launcher that will copy a text to the clipboar

    are you trying to copy a specific string to the clipboard or just whatever text you have selected? if it's the latter, you can always just middle click to paste whatever selection you have, rather than copying it to the clipboard and pasting it

Tags for this Thread

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
  •