Created
June 29, 2024 20:45
-
-
Save AJV009/3793dcea6fc65a5da5300ca093fc8b5b to your computer and use it in GitHub Desktop.
A small script I used to setup my workspace...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Function to get primary monitor dimensions | |
| get_primary_monitor_dimensions() { | |
| xrandr --query | awk '/ primary /{print $4}' | cut -d'+' -f1 | |
| } | |
| # Function to get primary monitor position | |
| get_primary_monitor_position() { | |
| xrandr --query | awk '/ primary /{print $4}' | cut -d'+' -f2,3 | |
| } | |
| # Function to calculate window positions and sizes | |
| calculate_window_geometry() { | |
| local monitor_size=$(get_primary_monitor_dimensions) | |
| local monitor_width=$(echo $monitor_size | cut -d'x' -f1) | |
| local monitor_height=$(echo $monitor_size | cut -d'x' -f2) | |
| # Calculate sizes (70% and 30% of monitor width) | |
| local large_width=$((monitor_width * 70 / 100)) | |
| local small_width=$((monitor_width * 30 / 100)) | |
| echo "$monitor_width $monitor_height $large_width $small_width" | |
| } | |
| # Get monitor dimensions and position | |
| read monitor_width monitor_height large_width small_width < <(calculate_window_geometry) | |
| read x_offset y_offset < <(get_primary_monitor_position) | |
| echo "Monitor dimensions: ${monitor_width}x${monitor_height}" | |
| echo "Window sizes: Large ${large_width}, Small ${small_width}" | |
| echo "Monitor offset: ${x_offset},${y_offset}" | |
| # Function to move and resize window | |
| move_and_resize_window() { | |
| local window_id=$1 | |
| local width=$2 | |
| local height=$3 | |
| local x=$4 | |
| local y=$5 | |
| wmctrl -i -r $window_id -b remove,maximized_vert,maximized_horz | |
| xdotool windowsize $window_id $width $height | |
| xdotool windowmove $window_id $((x + x_offset)) $((y + y_offset)) | |
| } | |
| # Launch first Brave window | |
| brave --new-window & | |
| sleep 2 # Wait for the window to open | |
| first_brave_id=$(xdotool search --sync --onlyvisible --class "brave" | tail -1) | |
| move_and_resize_window $first_brave_id $large_width $monitor_height 0 0 | |
| #Click and open my work group | |
| sleep 2 | |
| xdotool mousemove --sync 40 150 click 1 | |
| # close default tab | |
| sleep 1 | |
| xdotool mousemove --sync 215 76 click 1 | |
| # Open the 2nd mail tab | |
| sleep 1 | |
| xdotool mousemove --sync 700 76 click 1 | |
| sleep 1 | |
| # Launch second Brave window | |
| brave --new-window "https://app.todoist.com" & | |
| sleep 2 | |
| second_brave_id=$(xdotool search --sync --onlyvisible --class "brave" | grep -v $first_brave_id | tail -1) | |
| move_and_resize_window $second_brave_id $small_width $monitor_height $large_width 0 | |
| # Launch Slack | |
| slack & | |
| sleep 5 # Slack might take longer to start | |
| slack_id=$(xdotool search --sync --onlyvisible --class "slack" | tail -1) | |
| move_and_resize_window $slack_id $large_width $monitor_height 0 0 | |
| xdotool windowraise $slack_id | |
| echo "Workspace setup complete on primary monitor!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment