background


How to get the pid of the last executed command that was sent to the background in a bash shell

Recently we came to the need of writing a bash script that needed periodically to check if a specific process, that was started by the script, had ended and restart it (something like watchdog but with not so many features).

To achieve this, we used the one of the shell special parameters, the $!. Like all other special parameters $! may only be referenced and the user cannot make an assignment to it.

($!) Expands to the process ID of the job most recently placed into the background, whether executed as an asynchronous command or using the bg builtin command.

From GNU.org: https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#index-_0021-1

Example of Usage

In this example we wanted to get the PID of the application called server to be used later on in the script.


server &
echo $!; #This will print the process ID of the 'server' application


Gnome3: How to scale background image 3

Issue in your terminal the following to change the mode of how the background is displayed

gsettings set org.gnome.desktop.background picture-options "scaled"

We used “scaled” which will center the image to and will resize it to fit the screen if needed.
You could use another option if you like. To get the full list of available options issue the following in your terminal.

gsettings range org.gnome.desktop.background picture-options

It will produce a list similar to this

enum

  • ‘none’
  • ‘wallpaper’
  • ‘centered’
  • ‘scaled’
  • ‘stretched’
  • ‘zoom’
  • ‘spanned’

To reset to the default option use the following

gsettings reset org.gnome.desktop.background picture-options