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;









3

















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:



iconic 2 optimized.gif










share|improve this question




























  • 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


















3

















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:



iconic 2 optimized.gif










share|improve this question




























  • 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














3












3








3








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:



iconic 2 optimized.gif










share|improve this question

















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:



iconic 2 optimized.gif







command-line bash gnome-shell window-manager xdotool






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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

















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











1 Answer
1






active

oldest

votes


















4


















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.






share|improve this answer




























  • 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 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





    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












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
);



);














draft saved

draft discarded
















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









4


















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.






share|improve this answer




























  • 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 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





    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















4


















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.






share|improve this answer




























  • 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 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





    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













4














4










4









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.






share|improve this answer
















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.







share|improve this answer















share|improve this answer




share|improve this answer








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 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





    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











  • 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 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





    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


















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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









Popular posts from this blog

Tamil (spriik) Luke uk diar | Nawigatjuun

Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?