LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-03-2018, 03:29 PM   #1
jamtat
Member
 
Registered: Oct 2004
Distribution: Debian/Ubuntu, Arch, Gentoo, Void
Posts: 138

Rep: Reputation: 24
[SOLVED] Script won't run using key bindings (JWM centric)


This post will refer to a GNU/Linux desktop system running Arch and using the JWM window manager. I found a really nice little script at http://www.thelinuxrain.com/articles...r-translations and am trying to implement it on my system. I installed missing dependencies, copied over the script to my system, then chmod'd it. Testing from the command line reveals that it works as intended. Here is what the script looks like:
Code:
#!/bin/bash
xclip -o | trans -e google -b \
| tee >(yad --geometry=300x800+1550+100 --text-info  --wrap) >(xclip -i)
exit 0
However, to make the script operate optimally, I should invoke it using keystrokes. JWM is quite congenial to implementing custom key bindings and I've already set up more than one of these for running some simple little scripts I wrote for my system. Yet, when I try to implement keystrokes to run the script referenced above, I am unable to get it to work (nothing happens when I press the relevant keys). I've tried various permutations and have been over my .jwmrc file many times, but I cannot get it to work and am unable thus far to comprehend why I'm having these problems invoking the script using keystrokes.

In an attempt to do some troubleshooting, I redirected stderr to a file (my current key binding looks as follows:
Code:
<Key mask="4" key="t">exec:trans-paste.sh >>trans-paste_err.txt 2>&1</Key>
) The output written to that file, after having pressed the specified key combination, is
Code:
/path/to/trans-paste.sh: line 4: syntax error near unexpected token `('
/path/to/trans-paste.sh: line 4: `xclip -o | trans -e google -b | tee >(yad --geometry=300x800+1550+100 --text-info --wrap) >(xclip -i) exit 0'
Doing some searches on that error message led me to believe I should escape the parenthesis or quote them. I'm not real bash saavy, but my attempts at trying those sorts of things have not brought resolution. Of course I could well be doing something wrong.

So can anyone here provide any pointers on why I am seeing these results? Perhaps this is something peculiar to the way scripts are interpreted within JWM? Not sure where to turn for diagnosis of this issue, which has proved thus far to exceed my rather paltry technical acumen. TIA

Last edited by jamtat; 01-04-2018 at 09:54 AM.
 
Old 01-04-2018, 05:45 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
interesting.
i have tried the script, and it works.
if i change the first line from '#!/bin/bash' to '#!/bin/dash' i get a similar error:
Code:
/home/mus/bin/trans-paste: 6: /home/mus/bin/trans-paste: Syntax error: "(" unexpected
can you post output of
Code:
ls -l /bin/bash
bash --version
you might also want to try to tell jwm explicitely to use bash, like this:
Code:
bash -c trans-paste.sh
you can incorporate the logging into the script:
Code:
#!/bin/bash
exec &gt; trans-paste_err.txt 2&gt;&amp;1
...
 
Old 01-04-2018, 08:32 AM   #3
jamtat
Member
 
Registered: Oct 2004
Distribution: Debian/Ubuntu, Arch, Gentoo, Void
Posts: 138

Original Poster
Rep: Reputation: 24
Thanks for your response, ondoho.
Code:
ls -l /bin/bash
-rwxr-xr-x 1 root root 828320 Feb 14  2017 /bin/bash
and
Code:
bash --version
GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)
I know I tried the bash -c option at some point--as in
Code:
<Key mask="4" key="t">exec:bash -c trans-paste.sh</Key>
but I should probably give it another shot; I've tried so many variations that it's hard to keep track of which and the results of each.

Actually, just now trying the above key binding entry I now have success--thanks for the suggestion! I guess I had previously incorporated the bash -c option into the script itself rather than within the key binding line.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Script When Any Key Pressed, Run 2nd Script After Any Pause jakfish Linux - General 2 08-25-2016 06:47 AM
JWM panel button using script Fixit7 Puppy 3 07-06-2014 01:43 PM
JWM bindings: how to use the WINDOWS FLAG key? frenchn00b Linux - Desktop 4 01-10-2010 08:35 AM
Any JWM experts here? Need advice/help with JWM linus72 Linux - Desktop 2 07-07-2009 04:41 PM
In KDE, how to run a sh script from the key bindings ? Xeratul Linux - General 3 12-17-2006 12:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 08:19 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
Open Source Consulting | Domain Registration