Is there a dynamic-multiple-monitor friendly desktop environment available for Ubuntu?

Solution 1:

I am providing you two shell scripts. It will help you to save your arrangement of windows positions and size. If somehow your desired windows arrangements get disturbed, you will be able to restore those arrangements with exact windows size and positions for all windows using these script.

You need to install wmctrl unless you already have it. Install via terminal,

sudo apt-get install wmctrl

Script to save windows configuration

# Script_Name: save_window_conf.sh
#!/bin/bash
if [ -f $HOME/.my_windows_config.txt ]; then
    echo -e "Information: Previous configuration file \"$HOME/.my_windows_config.txt\" already exists.\nTo save a new configuration remove it manually using the following command,\n\n\trm $HOME/.my_windows_config.txt"
    exit 1
else
    wmctrl -p -G -l | awk '($2 != -1)&&($3 != 0)&&($NF != "Desktop")' | awk '{print $1}' | while read mywinid
    do
        xwininfo -id "$mywinid" >> $HOME/.my_windows_config.txt
    done
fi

At execution the above script will save your windows position and size for all your open windows to a file named .my_windows_config.txt in your home directory. It is a hidden text file.

Script to reload the windows configuration

# Script_Name: load_window_conf.sh
#!/bin/bash

file=$HOME/.my_windows_config.txt
declare -a mywinid
declare -a x
declare -a y
declare -a width
declare -a height

nl=$(cat "$file" | grep xwininfo |wc -l)

for i in $(seq 1 $nl)
do
    mywinid[i]=$(cat "$file" | grep "xwininfo" | awk -v p="$i" '{if(NR==p) print $4}')
    x[i]=$(cat "$file" | grep "Absolute upper-left X" | awk -v p="$i" '{if(NR==p) print $NF}')
    y[i]=$(cat "$file" | grep "Absolute upper-left Y" | awk -v p="$i" '{if(NR==p) print $NF}')
    width[i]=$(cat "$file" | grep "Width" | awk -v p="$i" '{if(NR==p) print $NF}')
    height[i]=$(cat "$file" | grep "Height" | awk -v p="$i" '{if(NR==p) print $NF}')
done

for it in $(seq 1 $nl)
do
    wmctrl -i -r "${mywinid[$it]}" -e 0,"${x[$it]}","${y[$it]}","${width[it]}","${height[it]}"
done

When you execute the second script it will restore your windows position with exact size for all your windows.

Usage

Save these scripts in your $HOME/bin/ directory. Add $HOME/bin/ in your PATH. For this add these lines at the end of your $HOME/.bashrc

PATH=$HOME/bin:$PATH
export PATH

It will enable you execute those scripts with their name only. Give the scripts execution permission,

chmod +x $HOME/bin/save_window_conf.sh
chmod +x $HOME/bin/load_window_conf.sh

To save the configuration in your $HOME/.my_windows_config.txt

After you open and adjusted all your windows run in terminal,

save_window_conf.sh

To reload the configuration from your $HOME/.my_windows_config.txt

load_window_conf.sh

Hope it will solve your problem. Here is a screen shot,

enter image description here