abelsromero / bash-extensions

:computer: Custom Bash extensions
GNU Lesser General Public License v3.0
1 stars 0 forks source link

MacOs support #2

Open abelsromero opened 3 years ago

abelsromero commented 3 years ago

Document and make modular for MacOs support.

abelsromero commented 2 years ago

Document yabai cycleApp for v3 and v4: focus==1 is now has-focus==true

v3

cycleApp () {
    local focus_id=$(yabai -m query --windows | jq "map(select(.app == \"$1\" and .focused == 1))[].id")
    if [ -z "$focus_id" ]
    then
        open -a "/Applications/$2.app"
    else
        yabai -m window --focus "$(yabai -m query --windows | jq -re "[sort_by(.id, .frame) | reverse | .[] | select(.app == \"$1\") | .id] | nth(index($(yabai -m query --windows --window | jq -re ".id")) - 1)")"
    fi
}

v4

cycleApp () {
    local focus_id=$(yabai -m query --windows | jq "map(select(.app == \"$1\" and .\"has-focus\" == true))[].id")
    if [ -z "$focus_id" ]
    then
        open -a "/Applications/$2.app"
    else
        yabai -m window --focus "$(yabai -m query --windows | jq -re "[sort_by(.id, .frame) | reverse | .[] | select(.app == \"$1\") | .id] | nth(index($(yabai -m query --windows --window | jq -re ".id")) - 1)")"
    fi
}
abelsromero commented 1 year ago

install_to_path should use custom path since .local/bin is not available and we want a user local space.