Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save negativems/ae9f198cb3215247606a470dce04f103 to your computer and use it in GitHub Desktop.
Save negativems/ae9f198cb3215247606a470dce04f103 to your computer and use it in GitHub Desktop.

asd

.config/sxhkd/sxhkdrc

#...

# preselect the ratio with mouse scroll
super + ctrl + shift + {button4,button5}
   ~/.config/sxhkd/set_bspc_ratio.sh {up,down}
   
#...

.config/sxhkd/set_bspc_ratio.sh

#!/bin/bash

# Get the ID of the current node
node_id=$(bspc query -N -n)

# Get the JSON output of the node
node_info=$(bspc query -T -n $node_id)

# Extract the preselection values from the JSON output
preselection=$(echo $node_info | jq '.presel')
if [[ $preselection == "null" ]]; then
  exit 1
fi

# Extract the split direction and set the increase/decrease values accordingly
direction=$(echo $preselection | jq -r '.splitDir')
case $direction in
  west|north)
    increase="0.1"
    decrease="-0.1"
  ;;
  east|south)
    increase="-0.1"
    decrease="0.1"
  ;;
  *)
    exit 1
  ;;
esac

# Extract the current split ratio and adjust it based on the scroll direction
ratio=$(echo $preselection | jq '.splitRatio')
if [[ $1 == "up" ]]; then
  ratio=$(echo "$ratio + $increase" | bc)
else
  ratio=$(echo "$ratio + $decrease" | bc)
fi

# Set the new split ratio
bspc node $node_id -o $ratio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment