Skip to content

Instantly share code, notes, and snippets.

@charlesvardeman
Forked from alansikora/hyprland.conf
Created July 24, 2025 13:51
Show Gist options
  • Select an option

  • Save charlesvardeman/03f3b2e5da37055e572d51ead58c4cc4 to your computer and use it in GitHub Desktop.

Select an option

Save charlesvardeman/03f3b2e5da37055e572d51ead58c4cc4 to your computer and use it in GitHub Desktop.

Revisions

  1. @alansikora alansikora created this gist Jul 23, 2025.
    11 changes: 11 additions & 0 deletions hyprland.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/bin/bash

    # Workspaces - Dynamic configuration
    source = ~/.config/hypr/workspaces.conf

    # Run workspace manager on startup and monitor changes
    exec-once = ~/.config/hypr/workspace-manager.sh
    exec-once = socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | \
    while read line; do \
    [[ "$line" =~ ^monitor ]] && ~/.config/hypr/workspace-manager.sh; \
    done
    71 changes: 71 additions & 0 deletions workspace-manager.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    #!/bin/bash

    # Dynamic workspace manager for Hyprland
    # Assigns workspaces 1-5 to DP-1 (when available) and 6-10 to eDP-1
    # If only eDP-1 is available, all workspaces go to eDP-1

    # Check if monitors are connected
    dp1_connected=$(hyprctl monitors -j | jq -r '.[] | select(.name == "DP-1") | .name' 2>/dev/null)
    edp1_connected=$(hyprctl monitors -j | jq -r '.[] | select(.name == "eDP-1") | .name' 2>/dev/null)

    # Clear existing workspace assignments
    echo "# Dynamic workspace configuration - generated automatically" > ~/.config/hypr/workspaces.conf
    echo "# Generated at: $(date)" >> ~/.config/hypr/workspaces.conf
    echo "" >> ~/.config/hypr/workspaces.conf

    # Configure workspaces based on available monitors
    if [[ -n "$dp1_connected" && -n "$edp1_connected" ]]; then
    # Both monitors available
    echo "# Both DP-1 and eDP-1 are connected" >> ~/.config/hypr/workspaces.conf

    # Workspaces 1-5 on DP-1
    for i in {1..5}; do
    echo "workspace=$i, monitor:DP-1, persistent:true" >> ~/.config/hypr/workspaces.conf
    done

    # Workspaces 6-10 (0) on eDP-1
    for i in {6..9}; do
    echo "workspace=$i, monitor:eDP-1, persistent:true" >> ~/.config/hypr/workspaces.conf
    done
    echo "workspace=10, monitor:eDP-1, persistent:true" >> ~/.config/hypr/workspaces.conf

    # Set defaults
    echo "" >> ~/.config/hypr/workspaces.conf
    echo "# Default workspaces" >> ~/.config/hypr/workspaces.conf
    echo "workspace=1, monitor:DP-1, default:true" >> ~/.config/hypr/workspaces.conf
    echo "workspace=6, monitor:eDP-1, default:true" >> ~/.config/hypr/workspaces.conf

    elif [[ -n "$edp1_connected" ]]; then
    # Only eDP-1 available
    echo "# Only eDP-1 is connected - all workspaces on eDP-1" >> ~/.config/hypr/workspaces.conf

    # All workspaces 1-10 on eDP-1
    for i in {1..9}; do
    echo "workspace=$i, monitor:eDP-1, persistent:true" >> ~/.config/hypr/workspaces.conf
    done
    echo "workspace=10, monitor:eDP-1, persistent:true" >> ~/.config/hypr/workspaces.conf

    # Set default
    echo "" >> ~/.config/hypr/workspaces.conf
    echo "# Default workspace" >> ~/.config/hypr/workspaces.conf
    echo "workspace=1, monitor:eDP-1, default:true" >> ~/.config/hypr/workspaces.conf

    elif [[ -n "$dp1_connected" ]]; then
    # Only DP-1 available
    echo "# Only DP-1 is connected - all workspaces on DP-1" >> ~/.config/hypr/workspaces.conf

    # All workspaces 1-10 on DP-1
    for i in {1..9}; do
    echo "workspace=$i, monitor:DP-1, persistent:true" >> ~/.config/hypr/workspaces.conf
    done
    echo "workspace=10, monitor:DP-1, persistent:true" >> ~/.config/hypr/workspaces.conf

    # Set default
    echo "" >> ~/.config/hypr/workspaces.conf
    echo "# Default workspace" >> ~/.config/hypr/workspaces.conf
    echo "workspace=1, monitor:DP-1, default:true" >> ~/.config/hypr/workspaces.conf
    else
    echo "# No known monitors detected" >> ~/.config/hypr/workspaces.conf
    fi

    echo "Workspace configuration updated"