#!/bin/bash # by desgua - 2012/05/11 # # This script help to customize apps in selected viewports # # works with metacity # check if we have the needed tools tool1=$(which xdotool) tool2=$(which calc) if [ -z $tool1 ]; then echo "Xdotool is needed, do you want to install it now? [Y/n]" read a if [[ $a == "Y" || $a == "y" || $a = "" ]]; then sudo apt-get install xdotool else echo "Exiting then..." exit 1 fi fi if [ -z $tool2 ]; then echo "Calc is needed, do you want to install it now? [Y/n]" read a if [[ $a == "Y" || $a == "y" || $a = "" ]]; then sudo apt-get install apcalc else echo "Exiting then..." exit 1 fi fi # numbers of desktops nh=$(gconftool-2 -g /apps/metacity/general/num_workspaces) # backup any previous script mv ~/.sessionconf ~/.sessionconf.bak # create the new sessionconf file touch ~/.sessionconf echo "#!/bin/bash # # generated by desgua's script sleep 5" > ~/.sessionconf chmod +x ~/.sessionconf clear # Info echo "I will help to customize your session. " echo echo "You have "$nh" desktops. " echo # Select Viewport function selvvp { read -p "Please select the desktop: " ah if [[ "$ah" -gt "$nh" || "$ah" -lt "1" ]]; then echo echo "Horizontal viewport not found. Please try again." selvvp fi apvp } # Select App function apvp { echo " Please select the app you need at" $ah ": " read a aa=$(which $a) if [[ -z $aa ]]; then echo "App not found, please try again" apvp else ahc=$(calc $ah-1) echo "Got it." echo "xdotool set_desktop "$ahc >> ~/.sessionconf echo $a "&" >> ~/.sessionconf echo "sleep 1" >> ~/.sessionconf echo echo "Done!" read -n 1 -p "Configure another app? (Y/n)" a if [[ $a == "Y" || $a == "y" || $a = "" ]]; then selvvp else pt=$(xdg-user-dir HOME) ppt=$(echo $pt/.sessionconf) echo echo echo "Adding the script to startup applications" echo '[Desktop Entry] Type=Application' > ~/.config/autostart/sessionconf.desktop echo 'Exec='$ppt >> ~/.config/autostart/sessionconf.desktop echo 'Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true Name=Custumized script Comment=To launch apps in viewports' >> ~/.config/autostart/sessionconf.desktop echo "Exiting now. Hope you enjoyed" exit 0 fi fi } selvvp exit 0