Thanks to @Andreas_Hegenberg, I was able to achieve exactly what I wanted (tbh for years, never got around to trying and asking around).
It behaves just like I wanted:
When moving a window from one side to the other, it automatically takes the smaller size, all the way to the right / left. This is done by checking the didMove
variable.
After having moved a window from one side to the other, repeating the shortcut more times just toggles between the moveLeft
and moveLeftWide
/ moveRight
and moveRightWide
layouts.
These are my snap areas:
moveLeft moveLeftWide
+----+---------+----+ +----+---------+----+
|xxxx| | | |xxxx|xxxxxxxxx| |
|xxxx| | | |xxxx|xxxxxxxxx| |
+----+---------+----+ +----+---------+----+
moveRight moveRightWide
+----+---------+----+ +----+---------+----+
| | |xxxx| | |xxxxxxxxx|xxxx|
| | |xxxx| | |xxxxxxxxx|xxxx|
+----+---------+----+ +----+---------+----+
This is my script for the left side:
async function cycleThrough () {
let moveWideName = 'windowLeftMoveWide';
let didMoveName = 'didMove';
let moveWide = await callBTT('get_number_variable', {variable_name: moveWideName});
let didMove = await callBTT('get_string_variable', {variable_name: didMoveName});
if (moveWide === undefined) {
await callBTT('set_number_variable', {variable_name: moveWideName, to: false});
moveWide = false;
}
if (didMove === undefined) {
await callBTT('set_string_variable', {variable_name: didMoveName, to: 'left'});
didMove = 'left';
}
if (didMove == 'right') {
moveWide = false;
}
if (moveWide) {
callBTT('trigger_named_async_without_response', {trigger_name: 'moveLeftWide'});
}
else {
callBTT('trigger_named_async_without_response', {trigger_name: 'moveLeft'});
}
// increase the variable callBTT
await callBTT('set_number_variable', {variable_name: moveWideName, to: !moveWide});
// set the variable didMove
await callBTT('set_string_variable', {variable_name: didMoveName, to: 'left'});
// return to BTT
returnToBTT(variable);
}
cycleThrough();
And here almost the same stuff for the right:
async function cycleThrough () {
let moveWideName = 'windowRightMoveWide';
let didMoveName = 'didMove';
let moveWide = await callBTT('get_number_variable', {variable_name: moveWideName});
let didMove = await callBTT('get_string_variable', {variable_name: didMoveName});
if (moveWide === undefined) {
await callBTT('set_number_variable', {variable_name: moveWideName, to: false});
moveWide = false;
}
if (didMove === undefined) {
await callBTT('set_string_variable', {variable_name: didMoveName, to: 'right'});
didMove = 'right';
}
if (didMove == 'left') {
moveWide = false;
}
if (moveWide) {
callBTT('trigger_named_async_without_response', {trigger_name: 'moveRightWide'});
}
else {
callBTT('trigger_named_async_without_response', {trigger_name: 'moveRight'});
}
// increase the variable callBTT
await callBTT('set_number_variable', {variable_name: moveWideName, to: !moveWide});
// set the variable didMove
await callBTT('set_string_variable', {variable_name: didMoveName, to: 'right'});
// return to BTT
returnToBTT(moveWide);
}
cycleThrough();