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

Same shortcut for two different actions #334

Open
hamadahiro opened this issue Jan 20, 2024 · 1 comment
Open

Same shortcut for two different actions #334

hamadahiro opened this issue Jan 20, 2024 · 1 comment

Comments

@hamadahiro
Copy link

hamadahiro commented Jan 20, 2024

I have set up a shortcut in skhdrc to toggle the topmost of sketchybar using two different key combinations:

# sketchybar
fn - b : sketchybar --bar topmost=on
fn - m : sketchybar --bar topmost=off

Is it possible to toggle the topmost with just one combination? If topmost is "on", turn it "off", and vice versa?

@bustinbung
Copy link

One option would be to use sketchybar --query and jq to find if the value of the setting and decide what to do from there. For example:

# in a script file somewhere (I keep mine in ~/.config/skhd/scripts)

# -- topmost.sh -- #
#!/usr/bin/env bash

# queries sketchybar's bar element and returns a JSON object with properties
# jq filters for the "topmost" property in the object and returns true if the value of topmost is "on"
if $(sketchybar --query bar | jq '.topmost == "on"'); then
  # if topmost is on, turn off
  sketchybar --bar topmost=off
else
  # vice versa
  sketchybar --bar topmost=on
fi

Then in skhdrc:

fn - m : ~/.config/skhd/scripts/topmost.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants