How to write a command for hotkey that launch or restore minimized window
How to write a command that would launch an application or if it was already running, would restore the minimized window?
The solution was found.
For me it is:
C=`xdotool search --classname keepassx | tail -1`
if [ -z "$C" ]
then
keepassx &
else
xdotool windowactivate --sync $C
fi
linux debian kde
add a comment |
How to write a command that would launch an application or if it was already running, would restore the minimized window?
The solution was found.
For me it is:
C=`xdotool search --classname keepassx | tail -1`
if [ -z "$C" ]
then
keepassx &
else
xdotool windowactivate --sync $C
fi
linux debian kde
add a comment |
How to write a command that would launch an application or if it was already running, would restore the minimized window?
The solution was found.
For me it is:
C=`xdotool search --classname keepassx | tail -1`
if [ -z "$C" ]
then
keepassx &
else
xdotool windowactivate --sync $C
fi
linux debian kde
How to write a command that would launch an application or if it was already running, would restore the minimized window?
The solution was found.
For me it is:
C=`xdotool search --classname keepassx | tail -1`
if [ -z "$C" ]
then
keepassx &
else
xdotool windowactivate --sync $C
fi
linux debian kde
linux debian kde
edited 3 mins ago
Иван
asked 3 hours ago
ИванИван
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
With KDE there exists this solution. However this is not a command or script, but using the Graphical KDE Laucher program to review recently used programs and selecting which one you want to reopen.
I have found this relevant AskUbuntu thread. You can use different tools to accomplish your goals.
As user Jacob Vlijm points out you can use wmctrl
in conjunction with ps
to monitor graphical processes.
Create a cron job that runs every couple of minutes that loops through wmctrl
and ps
to create a log file. This is an extremely rough example:
#!/bin/bash
wmctrl -lp > /tmp/running.list
awk '{print $3}' /tmp/running.list | sed 's/[^0-9]*//g' > /tmp/pid.list
while read p; do
ps -o cmd= $p > /tmp/process.list
done </tmp/pid.list
This may not work exactly but gives you a rough idea of the kind of script you need to be running. Research a method that works best for you. Continuing on you need to create a script that will reference the results of this cron job as pointed out by user Jacob Vlijm:
Then all we need to do is run a loop with a period of a few seconds, comparing the (unique) list of processes, owning a window (=applications), with the list of a few seconds ago. If a process "left" the list, that's the most recently closed window. In short:
(Conceptual) overview of the loop (python style)
applications1 = get_applications()
while True:
time.sleep(3)
applications2 = get_applications()
closed = [app for app in applications1 if not app in applications2]
if closed:
most_recent = closed[0]
# store the process in a file, to be available to run as most recently closed
open(f, "wt").write(most_recent)
application1 = application2
where f is the path to a file where the most recent application is written to. Subsequently have another process/command start the application in the file and the setup is completed.
This script, (python or bash or whatever) needs to reference the file that we create using the cron job and you need to add a line to launch the recently closed application. You can then create a hotkey that references this script and viola! You now can instantly open the most recently closed graphical application. This can be expanded to any process or service but that is beyond the scope of your question.
Great thanks you for your answer. I wrote the wrong question. I mean "restore minimized window" not "recently closed". But your answer was helpful)
– Иван
6 mins ago
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',
autoActivateHeartbeat: false,
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%2f493006%2fhow-to-write-a-command-for-hotkey-that-launch-or-restore-minimized-window%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
With KDE there exists this solution. However this is not a command or script, but using the Graphical KDE Laucher program to review recently used programs and selecting which one you want to reopen.
I have found this relevant AskUbuntu thread. You can use different tools to accomplish your goals.
As user Jacob Vlijm points out you can use wmctrl
in conjunction with ps
to monitor graphical processes.
Create a cron job that runs every couple of minutes that loops through wmctrl
and ps
to create a log file. This is an extremely rough example:
#!/bin/bash
wmctrl -lp > /tmp/running.list
awk '{print $3}' /tmp/running.list | sed 's/[^0-9]*//g' > /tmp/pid.list
while read p; do
ps -o cmd= $p > /tmp/process.list
done </tmp/pid.list
This may not work exactly but gives you a rough idea of the kind of script you need to be running. Research a method that works best for you. Continuing on you need to create a script that will reference the results of this cron job as pointed out by user Jacob Vlijm:
Then all we need to do is run a loop with a period of a few seconds, comparing the (unique) list of processes, owning a window (=applications), with the list of a few seconds ago. If a process "left" the list, that's the most recently closed window. In short:
(Conceptual) overview of the loop (python style)
applications1 = get_applications()
while True:
time.sleep(3)
applications2 = get_applications()
closed = [app for app in applications1 if not app in applications2]
if closed:
most_recent = closed[0]
# store the process in a file, to be available to run as most recently closed
open(f, "wt").write(most_recent)
application1 = application2
where f is the path to a file where the most recent application is written to. Subsequently have another process/command start the application in the file and the setup is completed.
This script, (python or bash or whatever) needs to reference the file that we create using the cron job and you need to add a line to launch the recently closed application. You can then create a hotkey that references this script and viola! You now can instantly open the most recently closed graphical application. This can be expanded to any process or service but that is beyond the scope of your question.
Great thanks you for your answer. I wrote the wrong question. I mean "restore minimized window" not "recently closed". But your answer was helpful)
– Иван
6 mins ago
add a comment |
With KDE there exists this solution. However this is not a command or script, but using the Graphical KDE Laucher program to review recently used programs and selecting which one you want to reopen.
I have found this relevant AskUbuntu thread. You can use different tools to accomplish your goals.
As user Jacob Vlijm points out you can use wmctrl
in conjunction with ps
to monitor graphical processes.
Create a cron job that runs every couple of minutes that loops through wmctrl
and ps
to create a log file. This is an extremely rough example:
#!/bin/bash
wmctrl -lp > /tmp/running.list
awk '{print $3}' /tmp/running.list | sed 's/[^0-9]*//g' > /tmp/pid.list
while read p; do
ps -o cmd= $p > /tmp/process.list
done </tmp/pid.list
This may not work exactly but gives you a rough idea of the kind of script you need to be running. Research a method that works best for you. Continuing on you need to create a script that will reference the results of this cron job as pointed out by user Jacob Vlijm:
Then all we need to do is run a loop with a period of a few seconds, comparing the (unique) list of processes, owning a window (=applications), with the list of a few seconds ago. If a process "left" the list, that's the most recently closed window. In short:
(Conceptual) overview of the loop (python style)
applications1 = get_applications()
while True:
time.sleep(3)
applications2 = get_applications()
closed = [app for app in applications1 if not app in applications2]
if closed:
most_recent = closed[0]
# store the process in a file, to be available to run as most recently closed
open(f, "wt").write(most_recent)
application1 = application2
where f is the path to a file where the most recent application is written to. Subsequently have another process/command start the application in the file and the setup is completed.
This script, (python or bash or whatever) needs to reference the file that we create using the cron job and you need to add a line to launch the recently closed application. You can then create a hotkey that references this script and viola! You now can instantly open the most recently closed graphical application. This can be expanded to any process or service but that is beyond the scope of your question.
Great thanks you for your answer. I wrote the wrong question. I mean "restore minimized window" not "recently closed". But your answer was helpful)
– Иван
6 mins ago
add a comment |
With KDE there exists this solution. However this is not a command or script, but using the Graphical KDE Laucher program to review recently used programs and selecting which one you want to reopen.
I have found this relevant AskUbuntu thread. You can use different tools to accomplish your goals.
As user Jacob Vlijm points out you can use wmctrl
in conjunction with ps
to monitor graphical processes.
Create a cron job that runs every couple of minutes that loops through wmctrl
and ps
to create a log file. This is an extremely rough example:
#!/bin/bash
wmctrl -lp > /tmp/running.list
awk '{print $3}' /tmp/running.list | sed 's/[^0-9]*//g' > /tmp/pid.list
while read p; do
ps -o cmd= $p > /tmp/process.list
done </tmp/pid.list
This may not work exactly but gives you a rough idea of the kind of script you need to be running. Research a method that works best for you. Continuing on you need to create a script that will reference the results of this cron job as pointed out by user Jacob Vlijm:
Then all we need to do is run a loop with a period of a few seconds, comparing the (unique) list of processes, owning a window (=applications), with the list of a few seconds ago. If a process "left" the list, that's the most recently closed window. In short:
(Conceptual) overview of the loop (python style)
applications1 = get_applications()
while True:
time.sleep(3)
applications2 = get_applications()
closed = [app for app in applications1 if not app in applications2]
if closed:
most_recent = closed[0]
# store the process in a file, to be available to run as most recently closed
open(f, "wt").write(most_recent)
application1 = application2
where f is the path to a file where the most recent application is written to. Subsequently have another process/command start the application in the file and the setup is completed.
This script, (python or bash or whatever) needs to reference the file that we create using the cron job and you need to add a line to launch the recently closed application. You can then create a hotkey that references this script and viola! You now can instantly open the most recently closed graphical application. This can be expanded to any process or service but that is beyond the scope of your question.
With KDE there exists this solution. However this is not a command or script, but using the Graphical KDE Laucher program to review recently used programs and selecting which one you want to reopen.
I have found this relevant AskUbuntu thread. You can use different tools to accomplish your goals.
As user Jacob Vlijm points out you can use wmctrl
in conjunction with ps
to monitor graphical processes.
Create a cron job that runs every couple of minutes that loops through wmctrl
and ps
to create a log file. This is an extremely rough example:
#!/bin/bash
wmctrl -lp > /tmp/running.list
awk '{print $3}' /tmp/running.list | sed 's/[^0-9]*//g' > /tmp/pid.list
while read p; do
ps -o cmd= $p > /tmp/process.list
done </tmp/pid.list
This may not work exactly but gives you a rough idea of the kind of script you need to be running. Research a method that works best for you. Continuing on you need to create a script that will reference the results of this cron job as pointed out by user Jacob Vlijm:
Then all we need to do is run a loop with a period of a few seconds, comparing the (unique) list of processes, owning a window (=applications), with the list of a few seconds ago. If a process "left" the list, that's the most recently closed window. In short:
(Conceptual) overview of the loop (python style)
applications1 = get_applications()
while True:
time.sleep(3)
applications2 = get_applications()
closed = [app for app in applications1 if not app in applications2]
if closed:
most_recent = closed[0]
# store the process in a file, to be available to run as most recently closed
open(f, "wt").write(most_recent)
application1 = application2
where f is the path to a file where the most recent application is written to. Subsequently have another process/command start the application in the file and the setup is completed.
This script, (python or bash or whatever) needs to reference the file that we create using the cron job and you need to add a line to launch the recently closed application. You can then create a hotkey that references this script and viola! You now can instantly open the most recently closed graphical application. This can be expanded to any process or service but that is beyond the scope of your question.
answered 1 hour ago
kemotepkemotep
2,0313620
2,0313620
Great thanks you for your answer. I wrote the wrong question. I mean "restore minimized window" not "recently closed". But your answer was helpful)
– Иван
6 mins ago
add a comment |
Great thanks you for your answer. I wrote the wrong question. I mean "restore minimized window" not "recently closed". But your answer was helpful)
– Иван
6 mins ago
Great thanks you for your answer. I wrote the wrong question. I mean "restore minimized window" not "recently closed". But your answer was helpful)
– Иван
6 mins ago
Great thanks you for your answer. I wrote the wrong question. I mean "restore minimized window" not "recently closed". But your answer was helpful)
– Иван
6 mins ago
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%2f493006%2fhow-to-write-a-command-for-hotkey-that-launch-or-restore-minimized-window%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