Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/layouts/rtall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ execute_layout() {

local mon_width=$(jget width "$(bspc query -T -m)")

local want=$(( $master_size * $mon_width ))
local want=$(rcalc "$master_size * $mon_width")
local have=$(jget width "$(bspc query -T -n '@/2')")

bspc node '@/2' --resize left $((have - want)) 0
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/rwide.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ execute_layout() {

local mon_height=$(jget height "$(bspc query -T -m)")

local want=$(( $master_size * $mon_height ))
local want=$(rcalc "$master_size * $mon_width")
local have=$(jget height "$(bspc query -T -n '@/2')")

bspc node '@/2' --resize top 0 $((have - want))
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/tall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ execute_layout() {

local mon_width=$(jget width "$(bspc query -T -m)")

local want=$(( $master_size * $mon_width ))
local want=$(rcalc "$master_size * $mon_width")
local have=$(jget width "$(bspc query -T -n '@/1')")

bspc node '@/1' --resize right $((want - have)) 0
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/wide.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ execute_layout() {

local mon_height=$(jget height "$(bspc query -T -m)")

local want=$(( $master_size * $mon_height ))
local want=$(rcalc "$master_size * $mon_width")
local have=$(jget height "$(bspc query -T -n '@/1')")

bspc node '@/1' --resize bottom 0 $((want - have))
Expand Down
7 changes: 7 additions & 0 deletions src/utils/layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ auto_balance() {
# Balance the tree rooted at some node automatically.
bspc node "$1" -B
}

# calc to rounded integer
rcalc() {
expr=${@}

echo "scale=1; $expr" | bc | cut -d. -f1
Copy link
Author

@marcxjo marcxjo Jun 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that setting scale to 1 here allows folks to use fractional ratio representations like 1 / 3 (albeit with noticeably imperfect accuracy for irrational values with multi-digit or non-terminating decimal expansions).

}