Is it possible to start a command from bash and send a keystroke to it
up vote
2
down vote
favorite
I'm trying to start Firefox from bash and I want it to open the webconsole on start (this can be done by pressing F12 rigth after it started). Is there a bash command that starts the programm and sends the F12 key while starting? I already looked at xdotool and tried to create a bash script, that starts firefox and then sends the key with xdotool, but the xdotool command isn't run until I close firefox.
bash shell-script scripting
add a comment |
up vote
2
down vote
favorite
I'm trying to start Firefox from bash and I want it to open the webconsole on start (this can be done by pressing F12 rigth after it started). Is there a bash command that starts the programm and sends the F12 key while starting? I already looked at xdotool and tried to create a bash script, that starts firefox and then sends the key with xdotool, but the xdotool command isn't run until I close firefox.
bash shell-script scripting
1
Hmm, you could background firefox withfirefox &
and then kluge in asleep 7
or something to wait for firefox to spin up. A better solution might be to configure firefox to show the webconsole by default, but that might require an add-on or delving throughabout:config
?
– thrig
Sep 13 '15 at 19:59
I already searched for methods that start the webconsole, but the only option I found is the -jsconsole option and that starts the browserconsole instead of the webconsole. I haven't found any config options or addons that do this, thats why I'm searching for a way to do it in a bash script.
– user134007
Sep 13 '15 at 20:04
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm trying to start Firefox from bash and I want it to open the webconsole on start (this can be done by pressing F12 rigth after it started). Is there a bash command that starts the programm and sends the F12 key while starting? I already looked at xdotool and tried to create a bash script, that starts firefox and then sends the key with xdotool, but the xdotool command isn't run until I close firefox.
bash shell-script scripting
I'm trying to start Firefox from bash and I want it to open the webconsole on start (this can be done by pressing F12 rigth after it started). Is there a bash command that starts the programm and sends the F12 key while starting? I already looked at xdotool and tried to create a bash script, that starts firefox and then sends the key with xdotool, but the xdotool command isn't run until I close firefox.
bash shell-script scripting
bash shell-script scripting
edited yesterday
Rui F Ribeiro
38.6k1479128
38.6k1479128
asked Sep 13 '15 at 19:39
user134007
1
Hmm, you could background firefox withfirefox &
and then kluge in asleep 7
or something to wait for firefox to spin up. A better solution might be to configure firefox to show the webconsole by default, but that might require an add-on or delving throughabout:config
?
– thrig
Sep 13 '15 at 19:59
I already searched for methods that start the webconsole, but the only option I found is the -jsconsole option and that starts the browserconsole instead of the webconsole. I haven't found any config options or addons that do this, thats why I'm searching for a way to do it in a bash script.
– user134007
Sep 13 '15 at 20:04
add a comment |
1
Hmm, you could background firefox withfirefox &
and then kluge in asleep 7
or something to wait for firefox to spin up. A better solution might be to configure firefox to show the webconsole by default, but that might require an add-on or delving throughabout:config
?
– thrig
Sep 13 '15 at 19:59
I already searched for methods that start the webconsole, but the only option I found is the -jsconsole option and that starts the browserconsole instead of the webconsole. I haven't found any config options or addons that do this, thats why I'm searching for a way to do it in a bash script.
– user134007
Sep 13 '15 at 20:04
1
1
Hmm, you could background firefox with
firefox &
and then kluge in a sleep 7
or something to wait for firefox to spin up. A better solution might be to configure firefox to show the webconsole by default, but that might require an add-on or delving through about:config
?– thrig
Sep 13 '15 at 19:59
Hmm, you could background firefox with
firefox &
and then kluge in a sleep 7
or something to wait for firefox to spin up. A better solution might be to configure firefox to show the webconsole by default, but that might require an add-on or delving through about:config
?– thrig
Sep 13 '15 at 19:59
I already searched for methods that start the webconsole, but the only option I found is the -jsconsole option and that starts the browserconsole instead of the webconsole. I haven't found any config options or addons that do this, thats why I'm searching for a way to do it in a bash script.
– user134007
Sep 13 '15 at 20:04
I already searched for methods that start the webconsole, but the only option I found is the -jsconsole option and that starts the browserconsole instead of the webconsole. I haven't found any config options or addons that do this, thats why I'm searching for a way to do it in a bash script.
– user134007
Sep 13 '15 at 20:04
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
#!/bin/sh
set -e #abort if anything fails
firefox & #run firefox in the background
pid=$! #remember its pid
#Poll X until firefox sets up a window
#remember the X id of the window
while [ -z "$id" ]; do
id=$(xdotool search --onlyvisible --pid $pid)
sleep 0.1 #poll interval
done
#Bring the window to the front and send it the F12 key
xdotool windowactivate $id && xdotool key F12
disown "$pid"
This isn't very robust, though. Configuring firefox
to open the console by itself would be better.
1
Is there an urgent call from the NYSE for some risky business? If not thensleep 1
is fully sufficient.
– ott--
Sep 13 '15 at 20:37
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f229459%2fis-it-possible-to-start-a-command-from-bash-and-send-a-keystroke-to-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
#!/bin/sh
set -e #abort if anything fails
firefox & #run firefox in the background
pid=$! #remember its pid
#Poll X until firefox sets up a window
#remember the X id of the window
while [ -z "$id" ]; do
id=$(xdotool search --onlyvisible --pid $pid)
sleep 0.1 #poll interval
done
#Bring the window to the front and send it the F12 key
xdotool windowactivate $id && xdotool key F12
disown "$pid"
This isn't very robust, though. Configuring firefox
to open the console by itself would be better.
1
Is there an urgent call from the NYSE for some risky business? If not thensleep 1
is fully sufficient.
– ott--
Sep 13 '15 at 20:37
add a comment |
up vote
2
down vote
accepted
#!/bin/sh
set -e #abort if anything fails
firefox & #run firefox in the background
pid=$! #remember its pid
#Poll X until firefox sets up a window
#remember the X id of the window
while [ -z "$id" ]; do
id=$(xdotool search --onlyvisible --pid $pid)
sleep 0.1 #poll interval
done
#Bring the window to the front and send it the F12 key
xdotool windowactivate $id && xdotool key F12
disown "$pid"
This isn't very robust, though. Configuring firefox
to open the console by itself would be better.
1
Is there an urgent call from the NYSE for some risky business? If not thensleep 1
is fully sufficient.
– ott--
Sep 13 '15 at 20:37
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
#!/bin/sh
set -e #abort if anything fails
firefox & #run firefox in the background
pid=$! #remember its pid
#Poll X until firefox sets up a window
#remember the X id of the window
while [ -z "$id" ]; do
id=$(xdotool search --onlyvisible --pid $pid)
sleep 0.1 #poll interval
done
#Bring the window to the front and send it the F12 key
xdotool windowactivate $id && xdotool key F12
disown "$pid"
This isn't very robust, though. Configuring firefox
to open the console by itself would be better.
#!/bin/sh
set -e #abort if anything fails
firefox & #run firefox in the background
pid=$! #remember its pid
#Poll X until firefox sets up a window
#remember the X id of the window
while [ -z "$id" ]; do
id=$(xdotool search --onlyvisible --pid $pid)
sleep 0.1 #poll interval
done
#Bring the window to the front and send it the F12 key
xdotool windowactivate $id && xdotool key F12
disown "$pid"
This isn't very robust, though. Configuring firefox
to open the console by itself would be better.
edited Sep 13 '15 at 20:55
answered Sep 13 '15 at 20:06
PSkocik
17.6k44994
17.6k44994
1
Is there an urgent call from the NYSE for some risky business? If not thensleep 1
is fully sufficient.
– ott--
Sep 13 '15 at 20:37
add a comment |
1
Is there an urgent call from the NYSE for some risky business? If not thensleep 1
is fully sufficient.
– ott--
Sep 13 '15 at 20:37
1
1
Is there an urgent call from the NYSE for some risky business? If not then
sleep 1
is fully sufficient.– ott--
Sep 13 '15 at 20:37
Is there an urgent call from the NYSE for some risky business? If not then
sleep 1
is fully sufficient.– ott--
Sep 13 '15 at 20:37
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f229459%2fis-it-possible-to-start-a-command-from-bash-and-send-a-keystroke-to-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Hmm, you could background firefox with
firefox &
and then kluge in asleep 7
or something to wait for firefox to spin up. A better solution might be to configure firefox to show the webconsole by default, but that might require an add-on or delving throughabout:config
?– thrig
Sep 13 '15 at 19:59
I already searched for methods that start the webconsole, but the only option I found is the -jsconsole option and that starts the browserconsole instead of the webconsole. I haven't found any config options or addons that do this, thats why I'm searching for a way to do it in a bash script.
– user134007
Sep 13 '15 at 20:04