Posts: 93
Threads: 11
Joined: Oct 2014
Reputation:
0
[size=1em]Below we have some code that I expected would evaluate the variable %t before loading the relevant web page. It doesn't work it simply uses %t as a literal string.[/size]
Code:
/usr/bin/google-chrome-stable %U https://en.wikipedia.org/wiki/%t
[size=1em]I know the variable itself works fine so I'm wondering if the code is just badly formatted or the problem needs to be approached differently.[/size]
[size=1em]Thought this would be easy but now it's driving me mad. A green glow for the first one with a solution.[/size]
Don't believe half of what you see and none of what you hear
- Lou Reed
Posts: 1,849
Threads: 21
Joined: Sep 2015
Reputation:
0
Are you wanting "%t" to prompt for search string or reference an external file?
The below would populate a blank search box within wikipedia... Might get you closer...
Code:
http://en.wikipedia.org/wiki/Special:Search?search%QUERY%
I've used apps (SlickRun) to do very similar launch google a popup box would populate or I could add the string behind..
I'd type: "google" .. a pop up box prompting for string "Linux Lite"
or I could type: "google linux lite" both would yield same...
LL4.8 UEFI 64 bit ASUS E402W - AMD E2 (Quad) 1.5Ghz - 4GB - AMD Mullins Radeon R2
LL5.8 UEFI 64 bit Test UEFI Kangaroo (Mobile Desktop) - Atom X5-Z8500 1.44Ghz - 2GB - Intel HD Graphics
LL4.8 64 bit HP 6005- AMD Phenom II X2 - 8GB - AMD/ATI RS880 (HD4200)
LL3.8 32 bit Dell Inspiron Mini - Atom N270 1.6Ghz - 1GB - Intel Mobile 945GSE Express -- Shelved
BACK LL5.8 64 bit Dell Optiplex 160 (Thin) - Atom 230 1.6Ghz - 4GB-SiS 771/671 PCIE VGA - Print Server
Running Linux Lite since LL2.2
Posts: 93
Threads: 11
Joined: Oct 2014
Reputation:
0
11-20-2015, 08:49 PM
(This post was last modified: 11-20-2015, 08:53 PM by Duckeenie.)
Hi
[size=1em]firenice03,[/size]
I'm passing the variable from MOCP music player.[size=1em]
I want the browser to search wiki for the track that is playing. %t equates to the title of the track.[/size]
This is from the example config for mocp, it might help, didn't notice it earlier:
Code:
# Programs are run using execv(), not a shell, so you can't do things like
# redirecting the output to a file. The command string is split using blank
# characters as separators, the first element is the command to be executed
# and the rest are parameters, so if you use "echo Playing: %I" we run program
# echo (from $PATH) with 2 parameters: 'Playing:' string and the title. Even
# if the title contains spaces it's still one parameter and it's safe if it
# contains `rm -rf /`.
Don't believe half of what you see and none of what you hear
- Lou Reed
Posts: 688
Threads: 49
Joined: Jul 2014
Shell can't see %t as a variable
Variables are marked with $t or ${t}
Code:
t="elephant"
/usr/bin/google-chrome-stable %U https://en.wikipedia.org/wiki/$t
This will do:
Code:
/usr/bin/google-chrome-stable %U https://en.wikipedia.g/wiki/"$(mocp --format %title)"
"$(mocp --format %title)" - quotes are here because the title can contain spaces and you need a whole title to be a string
here a command (mocp --format %title) output is used
edit
Oh, you want to search wikipedia.
Next will open a browser and run a wiki search query
Code:
/usr/bin/google-chrome-stable %U https://en.wikipedia.g/wiki/?search="$(mocp --format %title)"
Special search:
Code:
/usr/bin/google-chrome-stable %U http://en.wikipedia.o/wiki/Special:Search?search="$(mocp --format %title)"
Posts: 93
Threads: 11
Joined: Oct 2014
Reputation:
0
11-20-2015, 10:16 PM
(This post was last modified: 11-20-2015, 10:25 PM by Duckeenie.)
(11-20-2015, 09:31 PM)misko_2083 link Wrote: Shell can't see %t as a variable
Variables are marked with $t or ${t}
Code:
t="elephant"
/usr/bin/google-chrome-stable %U https://en.wikipedia.org/wiki/$t
This will do:
Code:
/usr/bin/google-chrome-stable %U https://en.wikipedia.g/wiki/"$(mocp --format %title)"
"$(mocp --format %title)" - quotes are here because the title can contain spaces and you need a whole title to be a string
here a command (mocp --format %title) output is used
edit
Oh, you want to search wikipedia.
Next will open a browser and run a wiki search query
Code:
/usr/bin/google-chrome-stable %U https://en.wikipedia.g/wiki/?search="$(mocp --format %title)"
Special search:
Code:
/usr/bin/google-chrome-stable %U http://en.wikipedia.o/wiki/Special:Search?search="$(mocp --format %title)"
Right now I'm lifting my beer can toward the screen. Cheers!
Just had to edit %title out of your code because apparently the docs are wrong and this in fact returns artist - title - album. Using %t with your code did the job beautifully though.
Don't believe half of what you see and none of what you hear
- Lou Reed