xdotool how to select desktop send F5 and return?Desktop icons on left screen go down into black holewindow manager independent window resizingHow to modify xdotool output to export them as variables?How to make xdotool type Unicode charactersxdotool - how do I select text using shift+Home or shift+End?xdotool script to perform mouse moves and clicks17.10 workspaces, xdotool, and wmctrlxdotool: what are “class” and “classname” for a window?What are the differences between `key` and `type` commands of xdotool?How to make xdotool auto-click repeatedly?
True or False: If the product of n elements of a group is the identity element, it remains so no matter in what order the terms are multiplied.
Covering an 8x8 grid with X pentominoes
Why do Climate activists attack public transport?
"Du hast es gut", small talk meaning?
Use of expression "statistically significantly positive"
Would the minimum payment or full CC amount be considered monthly debt?
What set of notes can be used as a scale?
Did the Allies reverse the threads on secret microfilm-hiding buttons to thwart the Germans?
Shrinkage priors
Is it possible to commute 34km daily?
Take-Home Examination on Ordinary Differential Equations?
Make a haystack (with a needle)
Is there a more elegant way to express ((x == a and y == b) or (x == b and y == a))?
Twelve Labours - #03 Golden Hind
What is the proper way to allow the user of a plugin to modify settings?
How to answer to the "We do not want to create any precedent" argument in salary negotiation?
Protecting Seals from Forgery
"traversal failed: u: Bad message" when deleting an extremely large directory in Linux
What can I use for input conversion instead of scanf?
How does kinetic energy work in braking a vehicle?
Can Tankless & Conventional water heaters Join forces?
Would the professor leave the classroom if only 1 student uses their cellphone during class?
How to determine which sectors a file occupies on Windows?
Parents suppressing the teaching
xdotool how to select desktop send F5 and return?
Desktop icons on left screen go down into black holewindow manager independent window resizingHow to modify xdotool output to export them as variables?How to make xdotool type Unicode charactersxdotool - how do I select text using shift+Home or shift+End?xdotool script to perform mouse moves and clicks17.10 workspaces, xdotool, and wmctrlxdotool: what are “class” and “classname” for a window?What are the differences between `key` and `type` commands of xdotool?How to make xdotool auto-click repeatedly?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
It sounds simple; xdotool
selects desktop, simulates F5 key press and returns focus to calling window / program.
After googling though it doesn't sound simple anymore.
I need to do this from bash / gnome-shell.
Any ideas?
This project is related to this Q&A where the icons drop off the left screen into a black whole because of different sized monitors:
- Desktop icons just dropped down left screen into never-never land
Thanks to Podesta's help I created this code:
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
# TestIcons
This is what the screen looks like:
command-line bash gnome-shell window-manager xdotool
|
show 4 more comments
It sounds simple; xdotool
selects desktop, simulates F5 key press and returns focus to calling window / program.
After googling though it doesn't sound simple anymore.
I need to do this from bash / gnome-shell.
Any ideas?
This project is related to this Q&A where the icons drop off the left screen into a black whole because of different sized monitors:
- Desktop icons just dropped down left screen into never-never land
Thanks to Podesta's help I created this code:
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
# TestIcons
This is what the screen looks like:
command-line bash gnome-shell window-manager xdotool
What do you mean by selects deskstop?
– Podesta
May 30 at 7:19
@Podesta Moves focus to desktop. Something like moving cursor outside of current window and left clicking.
– WinEunuuchs2Unix
May 30 at 10:32
Something like minimizing all windows would do the trick? I played a bit with xdotool and it seems fairly straight forward. I'll try to post something. Is there anything in particular that you were or imagined you would have issues with?
– Podesta
May 30 at 10:40
@Podesta For years I've never used Show desktop because on restoring Conky doesn't reappear. However that is more a conky problem I should be solving and unrelated to this project.
– WinEunuuchs2Unix
May 30 at 10:42
If you only have one window open, then something likewindowminimize
should still do the trick without the show desktop shortcut. Otherwise you could also make it a loop to minimize everything.
– Podesta
May 30 at 10:48
|
show 4 more comments
It sounds simple; xdotool
selects desktop, simulates F5 key press and returns focus to calling window / program.
After googling though it doesn't sound simple anymore.
I need to do this from bash / gnome-shell.
Any ideas?
This project is related to this Q&A where the icons drop off the left screen into a black whole because of different sized monitors:
- Desktop icons just dropped down left screen into never-never land
Thanks to Podesta's help I created this code:
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
# TestIcons
This is what the screen looks like:
command-line bash gnome-shell window-manager xdotool
It sounds simple; xdotool
selects desktop, simulates F5 key press and returns focus to calling window / program.
After googling though it doesn't sound simple anymore.
I need to do this from bash / gnome-shell.
Any ideas?
This project is related to this Q&A where the icons drop off the left screen into a black whole because of different sized monitors:
- Desktop icons just dropped down left screen into never-never land
Thanks to Podesta's help I created this code:
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
# TestIcons
This is what the screen looks like:
command-line bash gnome-shell window-manager xdotool
command-line bash gnome-shell window-manager xdotool
edited May 31 at 1:04
WinEunuuchs2Unix
asked May 30 at 2:56
WinEunuuchs2UnixWinEunuuchs2Unix
59.4k18 gold badges119 silver badges233 bronze badges
59.4k18 gold badges119 silver badges233 bronze badges
What do you mean by selects deskstop?
– Podesta
May 30 at 7:19
@Podesta Moves focus to desktop. Something like moving cursor outside of current window and left clicking.
– WinEunuuchs2Unix
May 30 at 10:32
Something like minimizing all windows would do the trick? I played a bit with xdotool and it seems fairly straight forward. I'll try to post something. Is there anything in particular that you were or imagined you would have issues with?
– Podesta
May 30 at 10:40
@Podesta For years I've never used Show desktop because on restoring Conky doesn't reappear. However that is more a conky problem I should be solving and unrelated to this project.
– WinEunuuchs2Unix
May 30 at 10:42
If you only have one window open, then something likewindowminimize
should still do the trick without the show desktop shortcut. Otherwise you could also make it a loop to minimize everything.
– Podesta
May 30 at 10:48
|
show 4 more comments
What do you mean by selects deskstop?
– Podesta
May 30 at 7:19
@Podesta Moves focus to desktop. Something like moving cursor outside of current window and left clicking.
– WinEunuuchs2Unix
May 30 at 10:32
Something like minimizing all windows would do the trick? I played a bit with xdotool and it seems fairly straight forward. I'll try to post something. Is there anything in particular that you were or imagined you would have issues with?
– Podesta
May 30 at 10:40
@Podesta For years I've never used Show desktop because on restoring Conky doesn't reappear. However that is more a conky problem I should be solving and unrelated to this project.
– WinEunuuchs2Unix
May 30 at 10:42
If you only have one window open, then something likewindowminimize
should still do the trick without the show desktop shortcut. Otherwise you could also make it a loop to minimize everything.
– Podesta
May 30 at 10:48
What do you mean by selects deskstop?
– Podesta
May 30 at 7:19
What do you mean by selects deskstop?
– Podesta
May 30 at 7:19
@Podesta Moves focus to desktop. Something like moving cursor outside of current window and left clicking.
– WinEunuuchs2Unix
May 30 at 10:32
@Podesta Moves focus to desktop. Something like moving cursor outside of current window and left clicking.
– WinEunuuchs2Unix
May 30 at 10:32
Something like minimizing all windows would do the trick? I played a bit with xdotool and it seems fairly straight forward. I'll try to post something. Is there anything in particular that you were or imagined you would have issues with?
– Podesta
May 30 at 10:40
Something like minimizing all windows would do the trick? I played a bit with xdotool and it seems fairly straight forward. I'll try to post something. Is there anything in particular that you were or imagined you would have issues with?
– Podesta
May 30 at 10:40
@Podesta For years I've never used Show desktop because on restoring Conky doesn't reappear. However that is more a conky problem I should be solving and unrelated to this project.
– WinEunuuchs2Unix
May 30 at 10:42
@Podesta For years I've never used Show desktop because on restoring Conky doesn't reappear. However that is more a conky problem I should be solving and unrelated to this project.
– WinEunuuchs2Unix
May 30 at 10:42
If you only have one window open, then something like
windowminimize
should still do the trick without the show desktop shortcut. Otherwise you could also make it a loop to minimize everything.– Podesta
May 30 at 10:48
If you only have one window open, then something like
windowminimize
should still do the trick without the show desktop shortcut. Otherwise you could also make it a loop to minimize everything.– Podesta
May 30 at 10:48
|
show 4 more comments
1 Answer
1
active
oldest
votes
Script below work of @WinEunuuchs2Unix and is the final solution. My original answer is at the end.
#!/bin/bash
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
TestIcons
A few other xdotools
commands that can be useful in similar situation:
If your window manager has a show desktop command, it can be useful to minimize, and bring back all windows. Usually it is set to ctrl+alt+d
:
xdotool key ctrl+alt+d
If you want to save the currently active window, to later bring it back, you can use:
myWindow="$(xdotool getactivewindow)"
Ti minimize a window you can use. Adding it to a loop allows you to minimize all windows, as an alternative to the show dekstop.
xdotool windowminimize $(xdotool getactivewindow)
To bring the active window you saved back to the focus:
xdotool windowactivate "$myWindow"
To close the active window use:
xdotool getactivewindow windowkill
And most important, all those commands that you can use with active window, you can actually search and apply to specific cases. For example, searching for this specific window, based on the title.
xdotool search --desktop 0 --name "command line - xdotool" windowactivate
There are many different ways of searching for windows, based on the title, the class, if they are visible, etc. It can also manipulate both windows positions and the mouse. The manpage for xdotol is very comprehensive. Combining them with a bash script would give plenty of freedom to achieve most things.
I'll try it after work. Thanks
– WinEunuuchs2Unix
May 30 at 12:17
Don't worry. I'm not sure if it actually does what you want. I think part of it is that I don't use icons on the desktop, so I'm a bit lost. Posted it just to have something more concrete to discuss and iterate on.
– Podesta
May 30 at 12:19
1
Seems to be a glitch in my system when trying to restore windows. I received an "CRTC" error the first time and nothing restored. Second time no error but still nothing restored. I found a better solutionwmctrl -k on
show desktop andwmctrl -k off
restore windows (hide desktop?). If you would like to add that to your answer I'll gladly accept it for all your help. Later I'll change my question to show the final solution with.gif
animation. Hopefully tonight :)
– WinEunuuchs2Unix
May 30 at 23:16
2
I've updated the question with the.gif
. It's actually hard to record screen when windows are minimized by show desktop command.
– WinEunuuchs2Unix
May 31 at 1:05
1
I still want to accept your answer but you need to copy and paste my solution into it first.
– WinEunuuchs2Unix
Jun 1 at 1:04
|
show 7 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1147294%2fxdotool-how-to-select-desktop-send-f5-and-return%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
Script below work of @WinEunuuchs2Unix and is the final solution. My original answer is at the end.
#!/bin/bash
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
TestIcons
A few other xdotools
commands that can be useful in similar situation:
If your window manager has a show desktop command, it can be useful to minimize, and bring back all windows. Usually it is set to ctrl+alt+d
:
xdotool key ctrl+alt+d
If you want to save the currently active window, to later bring it back, you can use:
myWindow="$(xdotool getactivewindow)"
Ti minimize a window you can use. Adding it to a loop allows you to minimize all windows, as an alternative to the show dekstop.
xdotool windowminimize $(xdotool getactivewindow)
To bring the active window you saved back to the focus:
xdotool windowactivate "$myWindow"
To close the active window use:
xdotool getactivewindow windowkill
And most important, all those commands that you can use with active window, you can actually search and apply to specific cases. For example, searching for this specific window, based on the title.
xdotool search --desktop 0 --name "command line - xdotool" windowactivate
There are many different ways of searching for windows, based on the title, the class, if they are visible, etc. It can also manipulate both windows positions and the mouse. The manpage for xdotol is very comprehensive. Combining them with a bash script would give plenty of freedom to achieve most things.
I'll try it after work. Thanks
– WinEunuuchs2Unix
May 30 at 12:17
Don't worry. I'm not sure if it actually does what you want. I think part of it is that I don't use icons on the desktop, so I'm a bit lost. Posted it just to have something more concrete to discuss and iterate on.
– Podesta
May 30 at 12:19
1
Seems to be a glitch in my system when trying to restore windows. I received an "CRTC" error the first time and nothing restored. Second time no error but still nothing restored. I found a better solutionwmctrl -k on
show desktop andwmctrl -k off
restore windows (hide desktop?). If you would like to add that to your answer I'll gladly accept it for all your help. Later I'll change my question to show the final solution with.gif
animation. Hopefully tonight :)
– WinEunuuchs2Unix
May 30 at 23:16
2
I've updated the question with the.gif
. It's actually hard to record screen when windows are minimized by show desktop command.
– WinEunuuchs2Unix
May 31 at 1:05
1
I still want to accept your answer but you need to copy and paste my solution into it first.
– WinEunuuchs2Unix
Jun 1 at 1:04
|
show 7 more comments
Script below work of @WinEunuuchs2Unix and is the final solution. My original answer is at the end.
#!/bin/bash
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
TestIcons
A few other xdotools
commands that can be useful in similar situation:
If your window manager has a show desktop command, it can be useful to minimize, and bring back all windows. Usually it is set to ctrl+alt+d
:
xdotool key ctrl+alt+d
If you want to save the currently active window, to later bring it back, you can use:
myWindow="$(xdotool getactivewindow)"
Ti minimize a window you can use. Adding it to a loop allows you to minimize all windows, as an alternative to the show dekstop.
xdotool windowminimize $(xdotool getactivewindow)
To bring the active window you saved back to the focus:
xdotool windowactivate "$myWindow"
To close the active window use:
xdotool getactivewindow windowkill
And most important, all those commands that you can use with active window, you can actually search and apply to specific cases. For example, searching for this specific window, based on the title.
xdotool search --desktop 0 --name "command line - xdotool" windowactivate
There are many different ways of searching for windows, based on the title, the class, if they are visible, etc. It can also manipulate both windows positions and the mouse. The manpage for xdotol is very comprehensive. Combining them with a bash script would give plenty of freedom to achieve most things.
I'll try it after work. Thanks
– WinEunuuchs2Unix
May 30 at 12:17
Don't worry. I'm not sure if it actually does what you want. I think part of it is that I don't use icons on the desktop, so I'm a bit lost. Posted it just to have something more concrete to discuss and iterate on.
– Podesta
May 30 at 12:19
1
Seems to be a glitch in my system when trying to restore windows. I received an "CRTC" error the first time and nothing restored. Second time no error but still nothing restored. I found a better solutionwmctrl -k on
show desktop andwmctrl -k off
restore windows (hide desktop?). If you would like to add that to your answer I'll gladly accept it for all your help. Later I'll change my question to show the final solution with.gif
animation. Hopefully tonight :)
– WinEunuuchs2Unix
May 30 at 23:16
2
I've updated the question with the.gif
. It's actually hard to record screen when windows are minimized by show desktop command.
– WinEunuuchs2Unix
May 31 at 1:05
1
I still want to accept your answer but you need to copy and paste my solution into it first.
– WinEunuuchs2Unix
Jun 1 at 1:04
|
show 7 more comments
Script below work of @WinEunuuchs2Unix and is the final solution. My original answer is at the end.
#!/bin/bash
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
TestIcons
A few other xdotools
commands that can be useful in similar situation:
If your window manager has a show desktop command, it can be useful to minimize, and bring back all windows. Usually it is set to ctrl+alt+d
:
xdotool key ctrl+alt+d
If you want to save the currently active window, to later bring it back, you can use:
myWindow="$(xdotool getactivewindow)"
Ti minimize a window you can use. Adding it to a loop allows you to minimize all windows, as an alternative to the show dekstop.
xdotool windowminimize $(xdotool getactivewindow)
To bring the active window you saved back to the focus:
xdotool windowactivate "$myWindow"
To close the active window use:
xdotool getactivewindow windowkill
And most important, all those commands that you can use with active window, you can actually search and apply to specific cases. For example, searching for this specific window, based on the title.
xdotool search --desktop 0 --name "command line - xdotool" windowactivate
There are many different ways of searching for windows, based on the title, the class, if they are visible, etc. It can also manipulate both windows positions and the mouse. The manpage for xdotol is very comprehensive. Combining them with a bash script would give plenty of freedom to achieve most things.
Script below work of @WinEunuuchs2Unix and is the final solution. My original answer is at the end.
#!/bin/bash
TestIcons () [[ $TestSeconds == 0 ]] && TestSeconds=5
local i Position File
for (( i=0; i<$#IconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$IconsArr[((i+ICON_NAME_NDX))]"
Position="$IconsArr[((i+ICON_COL_NDX))],$IconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
sleep $TestSeconds # Pause for view
wmctrl -k off # Restore windows
for (( i=0; i<$#OldIconsArr[@]; i=i+ICON_FLD_CNT )) ; do
File="$ICONS_DIR"/"$OldIconsArr[((i+ICON_NAME_NDX))]"
Position="$OldIconsArr[((i+ICON_COL_NDX))],$OldIconsArr[((i+ICON_ROW_NDX))]"
gvfs-set-attribute -t string "$File"
'metadata::nautilus-icon-position' "$Position"
done
wmctrl -k on # Show desktop
xdotool key F5 # Refresh desktop (show icon new positions)
wmctrl -k off # Restore windows
TestIcons
A few other xdotools
commands that can be useful in similar situation:
If your window manager has a show desktop command, it can be useful to minimize, and bring back all windows. Usually it is set to ctrl+alt+d
:
xdotool key ctrl+alt+d
If you want to save the currently active window, to later bring it back, you can use:
myWindow="$(xdotool getactivewindow)"
Ti minimize a window you can use. Adding it to a loop allows you to minimize all windows, as an alternative to the show dekstop.
xdotool windowminimize $(xdotool getactivewindow)
To bring the active window you saved back to the focus:
xdotool windowactivate "$myWindow"
To close the active window use:
xdotool getactivewindow windowkill
And most important, all those commands that you can use with active window, you can actually search and apply to specific cases. For example, searching for this specific window, based on the title.
xdotool search --desktop 0 --name "command line - xdotool" windowactivate
There are many different ways of searching for windows, based on the title, the class, if they are visible, etc. It can also manipulate both windows positions and the mouse. The manpage for xdotol is very comprehensive. Combining them with a bash script would give plenty of freedom to achieve most things.
edited Jun 1 at 1:36
answered May 30 at 12:13
PodestaPodesta
7552 silver badges11 bronze badges
7552 silver badges11 bronze badges
I'll try it after work. Thanks
– WinEunuuchs2Unix
May 30 at 12:17
Don't worry. I'm not sure if it actually does what you want. I think part of it is that I don't use icons on the desktop, so I'm a bit lost. Posted it just to have something more concrete to discuss and iterate on.
– Podesta
May 30 at 12:19
1
Seems to be a glitch in my system when trying to restore windows. I received an "CRTC" error the first time and nothing restored. Second time no error but still nothing restored. I found a better solutionwmctrl -k on
show desktop andwmctrl -k off
restore windows (hide desktop?). If you would like to add that to your answer I'll gladly accept it for all your help. Later I'll change my question to show the final solution with.gif
animation. Hopefully tonight :)
– WinEunuuchs2Unix
May 30 at 23:16
2
I've updated the question with the.gif
. It's actually hard to record screen when windows are minimized by show desktop command.
– WinEunuuchs2Unix
May 31 at 1:05
1
I still want to accept your answer but you need to copy and paste my solution into it first.
– WinEunuuchs2Unix
Jun 1 at 1:04
|
show 7 more comments
I'll try it after work. Thanks
– WinEunuuchs2Unix
May 30 at 12:17
Don't worry. I'm not sure if it actually does what you want. I think part of it is that I don't use icons on the desktop, so I'm a bit lost. Posted it just to have something more concrete to discuss and iterate on.
– Podesta
May 30 at 12:19
1
Seems to be a glitch in my system when trying to restore windows. I received an "CRTC" error the first time and nothing restored. Second time no error but still nothing restored. I found a better solutionwmctrl -k on
show desktop andwmctrl -k off
restore windows (hide desktop?). If you would like to add that to your answer I'll gladly accept it for all your help. Later I'll change my question to show the final solution with.gif
animation. Hopefully tonight :)
– WinEunuuchs2Unix
May 30 at 23:16
2
I've updated the question with the.gif
. It's actually hard to record screen when windows are minimized by show desktop command.
– WinEunuuchs2Unix
May 31 at 1:05
1
I still want to accept your answer but you need to copy and paste my solution into it first.
– WinEunuuchs2Unix
Jun 1 at 1:04
I'll try it after work. Thanks
– WinEunuuchs2Unix
May 30 at 12:17
I'll try it after work. Thanks
– WinEunuuchs2Unix
May 30 at 12:17
Don't worry. I'm not sure if it actually does what you want. I think part of it is that I don't use icons on the desktop, so I'm a bit lost. Posted it just to have something more concrete to discuss and iterate on.
– Podesta
May 30 at 12:19
Don't worry. I'm not sure if it actually does what you want. I think part of it is that I don't use icons on the desktop, so I'm a bit lost. Posted it just to have something more concrete to discuss and iterate on.
– Podesta
May 30 at 12:19
1
1
Seems to be a glitch in my system when trying to restore windows. I received an "CRTC" error the first time and nothing restored. Second time no error but still nothing restored. I found a better solution
wmctrl -k on
show desktop and wmctrl -k off
restore windows (hide desktop?). If you would like to add that to your answer I'll gladly accept it for all your help. Later I'll change my question to show the final solution with .gif
animation. Hopefully tonight :)– WinEunuuchs2Unix
May 30 at 23:16
Seems to be a glitch in my system when trying to restore windows. I received an "CRTC" error the first time and nothing restored. Second time no error but still nothing restored. I found a better solution
wmctrl -k on
show desktop and wmctrl -k off
restore windows (hide desktop?). If you would like to add that to your answer I'll gladly accept it for all your help. Later I'll change my question to show the final solution with .gif
animation. Hopefully tonight :)– WinEunuuchs2Unix
May 30 at 23:16
2
2
I've updated the question with the
.gif
. It's actually hard to record screen when windows are minimized by show desktop command.– WinEunuuchs2Unix
May 31 at 1:05
I've updated the question with the
.gif
. It's actually hard to record screen when windows are minimized by show desktop command.– WinEunuuchs2Unix
May 31 at 1:05
1
1
I still want to accept your answer but you need to copy and paste my solution into it first.
– WinEunuuchs2Unix
Jun 1 at 1:04
I still want to accept your answer but you need to copy and paste my solution into it first.
– WinEunuuchs2Unix
Jun 1 at 1:04
|
show 7 more comments
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1147294%2fxdotool-how-to-select-desktop-send-f5-and-return%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
What do you mean by selects deskstop?
– Podesta
May 30 at 7:19
@Podesta Moves focus to desktop. Something like moving cursor outside of current window and left clicking.
– WinEunuuchs2Unix
May 30 at 10:32
Something like minimizing all windows would do the trick? I played a bit with xdotool and it seems fairly straight forward. I'll try to post something. Is there anything in particular that you were or imagined you would have issues with?
– Podesta
May 30 at 10:40
@Podesta For years I've never used Show desktop because on restoring Conky doesn't reappear. However that is more a conky problem I should be solving and unrelated to this project.
– WinEunuuchs2Unix
May 30 at 10:42
If you only have one window open, then something like
windowminimize
should still do the trick without the show desktop shortcut. Otherwise you could also make it a loop to minimize everything.– Podesta
May 30 at 10:48