Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle border option would be nice #74

Open
thomasbecker opened this issue Mar 8, 2024 · 1 comment
Open

Toggle border option would be nice #74

thomasbecker opened this issue Mar 8, 2024 · 1 comment
Labels
enhancement New feature or request PR welcome A PR for this feature will likely be merged

Comments

@thomasbecker
Copy link

First of all: Thx for all the work you put in jankyborders and sketchy bar.

Would be nice to have a toggle border command. Currently I'm toggling yabai gap/padding and jankyborder with this skhd mapping which works, but is a little hacky:

alt - p : yabai -m space --toggle padding ; yabai -m space --toggle gap ; if [[ -f /tmp/borders ]]; then borders width=0 ; rm /tmp/borders ; else borders width=5 ; touch /tmp/borders ; fi
@FelixKratz FelixKratz added enhancement New feature or request PR welcome A PR for this feature will likely be merged labels Mar 8, 2024
@Mccranky83
Copy link

alt - p : yabai -m space --toggle padding ; yabai -m space --toggle gap ; if [[ -f /tmp/borders ]]; then borders width=0 ; rm /tmp/borders ; else borders width=5 ; touch /tmp/borders ; fi

Because the padding does not take into account the width of the borders, I reckon the state of the borders should match that of yabai's padding. Say if the initial state has both padding and borders toggled on, and [[ -f /tmp/borders ]] is falsy, then skhd should map to borders width=0; touch /tmp/borders, thus turning both padding and borders off.

Frankly, what I'm trying to say is that the value assigned to borders' width in thomasbecker's command should be flipped.

alt - a : yabai -m space --toggle padding; yabai -m space --toggle gap; if [[ -f /tmp/borders ]]; then borders width=5; rm -rf /tmp/borders; else touch /tmp/borders; borders width=0; fi

Still, the padding and borders may not be coordinated at all, because the initial state is not anchored. Currently, I use this script and toggle borders alongside yabai paddings:

#!/usr/bin/env zsh

file_path=~/.config/borders/switch

flags=($(awk '{ print $NF }' $file_path))

toggle_setting() {
  local setting=$1
  local bool_value=$2
  sed -i "" "s/${setting}:.*/${setting}: ${bool_value}/" $file_path
}

if [[ ${flags[0]} = ${flags[1]} && ${flags[1]} = "on" ]]; then
  toggle_setting "borders" "off"
  borders width=0
  toggle_setting "padding" "off"
  yabai -m space --toggle padding
  yabai -m space --toggle gap
elif [[ ${flags[0]} = ${flags[1]} && ${flags[1]} = "off" ]]; then
  toggle_setting "borders" "on"
  borders width=5
  toggle_setting "padding" "on"
  yabai -m space --toggle padding
  yabai -m space --toggle gap
elif [[ ${flags[0]} = "off" && ${flags[1]} = "on" ]]; then
  toggle_setting "padding" "on"
  yabai -m space --toggle padding
  yabai -m space --toggle gap
elif [[ ${flags[0]} = "on" && ${flags[1]} = "off" ]]; then
  toggle_setting "padding" "off"
  yabai -m space --toggle padding
  yabai -m space --toggle gap
fi

awk '{ print $1, $NF }' $file_path
# Toggle desktop offset
alt - a : sh $HOME/.local/share/my_scripts/toggle_borders.sh
## switch is a text file containing two lines
padding: on
borders: on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR welcome A PR for this feature will likely be merged
Projects
None yet
Development

No branches or pull requests

3 participants