How to restore session after login?

I am looking for a way how to restore open windows (ideally even tabs and the paths in the terminal, but that’s not essential) after login, as known from the Mac. Basically it works when using hibernation, but this sometimes causes trouble (not shutting down but rebooting, black screen, external devices not connecting) so that I end up with a fresh reboot, and usually I don’t even need a precise snapshot. I would simply save all open documents and shut down, and next time boot again and log in to see the previously used apps.

1 Like

Hi @xtoph!

There is this setting in “dconf”:


I haven’t tried it: I just leave my browser open when I log out. That way I can restore my tabs and that’s enough for me. :face_with_hand_over_mouth:

Try and let us know how it goes.

PS: But perhaps you should install “gnome-session” first: “gnome-session-bin” is already installed, but not “gnome-session”.

1 Like

Thank you for your fast reply!

I installed gnome-session and enabled auto-save-session. Unfortunately, no immediate success when logging out and logging in again. I also tried auto-save-session-one-shot.

Maybe it’s not yet implemented?

I also use the tab restoration feature, that saves me some headaches.

1 Like

BTW gnome-session is specifically for the gnome-shell desktop. You shouldn’t install gnome-session.

Budgie uses budgie-session.

Basically restoring the session after login isnt a capability available in either budgie nor gnome.

Rather than shutting down, startup and login probably just easier to suspend your computer.

2 Likes

OK, that’s noted. I will remove gnome-sessions again. It would be a nice feature, but I understand if it’s not a priority.

1 Like

I don’t know if this is of help to anyone or not but I have a dual display / five workspace set up in which I use the left display for “primary” apps like perhaps my outliner app on the first workspace, the web browser on the second, a development IDE on the third, etc. and on the right display are all of the “common” apps that are used despite whatever project I’m currently working on. These apps consist of the text editor, the file manager, the system monitor, the terminal, a post-it notes app and my analog clock app. Each of these is “autostarted” at login the usual way (except they’re all run from a single bash script which itself is actually autostarted). After they’re all started, each app is automatically positioned on the workspace using wmctrl. So when I log into my Budgie desktop, all of these “common” apps automatically run and are then placed on the desktop exactly where I want them. They are also set to appear on all workspaces so that when I move between workspaces, I have them all at my fingertips. Of course, I also autostart/position some of the “primary” apps that are on my left display as well… I can share the two bash scripts used if anyone is interested. Here’s a .gif image of my set up as it looked about three months ago before I started exploiting the open real estate West of the clock with Xpad “post-it” notes (note that the terminal and text editor both share the same corner of he display due to limited space): Reddit - The heart of the internet

2 Likes

Yeah, these scripts could be interesting, at least the lines for one example app. Thanks!

1 Like

The first script (is just a convenience wrapper around wmctrl)…

#!/bin/bash

# placeapp - places app at given location on workspace
# 
# This bash script positions the specified GUI application 
# at the specified location on the workspace. 
#
# The following positional arguments are required:
#
#    <Title>    app window's title.
#    <X>        app window's X ordinate.
#    <Y>        app window's Y ordinate.
#    <Width>    app window's width.
#    <Height>   app window's height.
#
# Note: The Width and Height arguments can each be specified 
# as '-1' to leave the value unchanged.
#
# The following switch options can be provided:
#
#    "-t"   forces window always on [t]op of others
#    "-w"   forces window to be visible on all [w]orkspaces
#
# Example:
#
#    placeapp -w -t "My App" 3000 500 -1 -1
#
# ASSUMPTIONS
#
#    Window title provided should be unique. If an app has
#    two windows displayed having the same title, the result
#    is undefined.
#
##############################################################

HELP_TEXT="\nplaceapp - positions app at given location\n\n\
This bash script positions the given app at the given location.\n\n\
Usage:\n\n\
   placeapp [-t -w] <Title> <X> <Y> <Width> <Height>\n\n\
Where:\n\n\
   <Title> is the app window's title.\n\
   <X> is the app window's X ordinate.\n\
   <Y> is the app window's Y ordinate.\n\
   <Width> is the app window's width.\n\
   <Height> is the app window's height.\n\n\
Options:\n\n\
   -t   position above other windows\n\
   -w   visible across all workspaces\n\n\
Note: The Width and Height arguments can each be specified as '-1'\n\
to leave the value unchanged.\n\n"

# Process any optional arguments:

SWITCH_T=false
SWITCH_W=false

while getopts "tw" opt; do
  case $opt in
    t) SWITCH_T=true ;;
    w) SWITCH_W=true ;;
    \?) echo -e "$HELP_TEXT"; exit 2 ;;
  esac
done

# Process the required positional arguments:

shift $((OPTIND - 1))
if [ $# -eq 5 ] ; then

   # All arguments are provided.

   WIN_TITLE="$1"
      # The app's window title.
   APP_X="$2"
      # The app's X ordinate location.
   APP_Y="$3"
      # The app's Y ordinate location.
   APP_WIDTH="$4"
      # The app's X ordinate location.
   APP_HEIGHT="$5"
      # The app's Y ordinate location.

   # Position the app's window and then optionally set it to 
   # be visible on all workspaces and above all other windows:

   wmctrl -F -r "$WIN_TITLE" -e "0,$APP_X,$APP_Y,$APP_WIDTH,$APP_HEIGHT"

   if $SWITCH_T; then

      # Force the app's window to display
      # above any others:

      wmctrl -F -r "$WIN_TITLE" -b "add,above"
   fi
   
   if $SWITCH_W; then 

      # Force the app's window to display
      # across all workspaces:

      wmctrl -F -r "$WIN_TITLE" -b "add,sticky"
   fi
else

   # No arguments were provided. Display help:

   echo -e "$HELP_TEXT"
   exit 1
fi

exit 0

This second script uses the first one and is run from the “autostart” mechanism. Of course, you’ll need to edit app names, edit x, y, width and height values…

#!/bin/bash
#
# launch-and-place-autostart-apps - launches/positions autostart apps
#
# This bash script launches and positions all of my autostart apps.
#
#####################################################################

hiero &
tilix &
gedit &
nemo &
clockmaker Ubuntu-1 --size 300 &
gnome-system-monitor &

sleep 10

placeapp "Hiero" 917 15 1043 1086
placeapp -w "ClockMaker" 3150 245 -1 -1
placeapp -w "Tilix: bwblock@ENIAC: ~" 1880 156 882 515
placeapp -w "Untitled Document 1 - gedit" 1880 156 882 515
placeapp -w "Home" 1925 615 795 430
placeapp -w "System Monitor" 2700 630 840 430
2 Likes