#!/bin/bash # Define commands to run in each terminal commands=( "/sbin/ifconfig -a" "top" "ping -c 5 google.com" "tail -f /var/log/syslog" "htop" ) # Get screen dimensions screen_width=$(xdpyinfo | awk '/dimensions:/ {print $2}' | cut -d 'x' -f 1) screen_height=$(xdpyinfo | awk '/dimensions:/ {print $2}' | cut -d 'x' -f 2) # Define number of rows and columns for window arrangement rows=2 cols=3 # Calculate window width and height window_width=$((screen_width / cols)) window_height=$((screen_height / rows)) # Function to launch and arrange terminals launch_terminal() { local cmd=$1 local row=$2 local col=$3 gnome-terminal -- bash -c "$cmd; exec bash" & # Get the window ID of the most recent gnome-terminal sleep 0.5 window_id=$(wmctrl -l | grep -m 1 "$(hostname)" | awk '{print $1}') # Calculate position x=$((col * window_width)) y=$((row * window_height)) # Move and resize window wmctrl -i -r $window_id -e 0,$x,$y,$window_width,$window_height } # Launch each command in a separate terminal for i in "${!commands[@]}"; do row=$((i / cols)) col=$((i % cols)) launch_terminal "${commands[i]}" $row $col done