Skip to content

setgapsex

Bakkeby edited this page Feb 27, 2024 · 6 revisions
Function Expected argument Default keybinding
setgapsex 2155876111 N/A

The setgapsex function is an external function that allow for all gaps to specified in one call.

The value passed to this function consists of four bytes (one for each of the gaps) that are bit shifted to fit into an integer.

A byte has 8 bits and the uppermost bit is used to indicate that the existing gap value is to be kept as-is.

The reason for this is two-fold:

  • there is no need to know what the existing gaps are set to and
  • it allows for gaps to be set to 0

This also means that the maximum gap value that can be set using this method is 127, which should be sufficient for most situations.

The bytes are arranged from uppermost to lowest:

  • outer horizontal (oh)
  • outer vertical (ov)
  • inner horizontal (ih)
  • inner vertical (iv)

Binary example setting inner gaps to 15 pixels:

oh ov ih iv
10000000 10000000 00001111 00001111
keep as-is keep as-is 15px 15px

Which combined gives a binary value of 10000000100000000000111100001111 which in decimal is 2155876111.

If gaps are disabled for the current workspace when this function is called then they will be enabled automatically.

External command:

$ duskc run_command setgapsex 2155876111  # set inner gaps to 15 pixels, keep outer gaps as-is

Example shell script generating the value:

#!/bin/sh

if [ -z $1 ] || [ -z $2 ] || [ -z $3 ] || [ -z $4 ]; then
    echo "Usage: setgaps oh ov ih iv"
    exit
fi

[ $1 = -1 ] && oh=128 || oh=$1
[ $2 = -1 ] && ov=128 || ov=$2
[ $3 = -1 ] && ih=128 || ih=$3
[ $4 = -1 ] && iv=128 || iv=$4

duskc run_command setgapsex $(((oh << 24) + (ov << 16) + (ih << 8) + iv))

Back to Functions > Gaps.

Clone this wiki locally