FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.65k stars 86 forks source link

Dynamic Variables as Property Values #246

Closed FelixKratz closed 2 years ago

FelixKratz commented 2 years ago

I was thinking about a system where sketchybar would recognize a set of predetermined variables and substitute them accordingly.

E.g. I could imagine having commonly used system information accessible via these in an "f-string"-like pattern:

sketchybar --set window_info title=f"{front_app.name}: {front_app.title}"

This would be expanded dynamically by sketchybar itself and sketchybar would listen for changes in any of those dynamic variables and update the item accordingly.

Many "standard" items could make use of this, e.g. the time could be displayed via something like this:

sketchybar --set clock icon=f"{clock.day} {clock.date}" label=f"{clock.time}"

without the need of an additional script.

Or a CPU indicator would look like this:

sketchybar --set cpu label=f"{cpu.total} ({cpu.user} / {cpu.system})"

Of course, this will not change anything about the current possibilities and is only an additional option to easily and, especially, as low overhead as possible get some "standard" items running without shelling out to external scripts.

Please tell me your thoughts. If you have additional ideas for the specific syntax please comment them below. I am not sure currently if this might be fracturing the configuration a bit too much or if this is an elegant way to save some CPU cycles...

FelixKratz commented 2 years ago

I have implemented this feature but ended up not liking it, it is probably best to do this via an external helper program instead: https://github.com/FelixKratz/SketchyBarHelper

FelixKratz commented 2 years ago

I have added the example for a direct C implementation of a cpu utilization graph and the current time here: https://github.com/FelixKratz/SketchyBarHelper