I'm currently following a tutorial in Youtube on how to develop a gnome extension. My IDE is currently in workspace 2 and every time I restart my gnome-shell via Alt-F2+r I will be back in workspace 1. I've googled a a few keywords but I cannot find a helpful answer on how to customize the gnome-shell behavior during restart to stay on the current workspace. Some machine info that maybe helpful: Pop! OS: 20.04 Gnome: 3.36.3 Windowing System: X11

Thank you. Any help would be greatly appreciated!

1 Answer 1


I would suggest you write your own quick script using two things - while I assume you will know about local user's PATH and such, I'll be detailed:

  1. Replace the current Gnome shell; see caveats
  2. Switch workspace to the desired number
  3. Make script executable via GUI.

New file best goes to e.g. /home/user/.local/bin and you make sure your local path is loaded in ~/.profile (note that ~/.bashrc will not suffice as not necessarily loaded for GUI environments).

Script file - named e.g. gnomerestart.sh:

killall -3 gnome-shell & wait
xdotool set_desktop 1

Note that xdotool will start counting desktops at 0. Check xdotool get_num_desktops and xdotool get_desktop for total number of workspaces and the ID of the current one, respectively.

Make executable:

 chmod +x ~/.local/bin/gnomerestart.sh

Now check if your local bin is enabled in ~/.profile - add line if not already present.


To load the new profile you must make a new login once. If you want to override the "alt-F2+r" you might also just call it r and make sure to put the local path first in ~/.profile - which you should always do if you want to override system-wide commands.


If you want to dynamically define the current workspace to be loaded, the script must be adapted using:

old_number=$(xdotool get_desktop)
killall -3 gnome-shell & wait
xdotool set_desktop ${old_number}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .