toggle-layout.sh 600 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. # Script to toggle between master and monocle layouts for the active hyprland
  3. # workspace
  4. WS_INFO=$(hyprctl -j activeworkspace)
  5. WS_ID=$(echo "$WS_INFO" | jq -r '.id')
  6. CURRENT_LAYOUT=$(echo "$WS_INFO" | jq -r '.tiledLayout')
  7. if [ "$CURRENT_LAYOUT" = "master" ]; then
  8. hyprctl keyword "workspace $WS_ID,layout:monocle"
  9. else
  10. hyprctl keyword "workspace $WS_ID,layout:master"
  11. fi
  12. # Signal the persistent layout script accurately (by pid file)
  13. PID_FILE="${XDG_RUNTIME_DIR:-/tmp}/hypr_layout_persistent.pid"
  14. if [ -f "$PID_FILE" ]; then
  15. kill -USR1 "$(cat "$PID_FILE")" 2>/dev/null
  16. fi