diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-03 21:41:26 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-03 21:41:26 +1100 |
| commit | f8a6e84aa9b9229a1b527dcd1c662c1068759dd8 (patch) | |
| tree | 0893be4c5101a49dfbea6af52ad865d5e3f91481 /util.fish | |
| parent | completions: add for shell toggle cmd (diff) | |
| download | caelestia-cli-f8a6e84aa9b9229a1b527dcd1c662c1068759dd8.tar.gz caelestia-cli-f8a6e84aa9b9229a1b527dcd1c662c1068759dd8.tar.bz2 caelestia-cli-f8a6e84aa9b9229a1b527dcd1c662c1068759dd8.zip | |
toggles: refactor to have config
Config is in $XDG_CONFIG_HOME/caelestia/scripts.json
Selector is a jq selector using hyprland client data
Spawn is a command passed to uwsm app
Action is either spawn, move, or both
Extra cond is an extra shell command to check whether to do action (for easy disabling just put false or empty action)
Diffstat (limited to 'util.fish')
| -rw-r--r-- | util.fish | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -22,11 +22,30 @@ function input -a text _out blue INPUT $text $argv[2..] end +function get-config -a key + test -f $C_CONFIG_FILE && set -l value (jq -r ".$key" $C_CONFIG_FILE) + test -n "$value" -a "$value" != null && echo $value || jq -r ".$key" (dirname (status filename))/data/config.json +end + +function set-config -a key value + if test -f $C_CONFIG_FILE + set -l tmp (mktemp) + cp $C_CONFIG_FILE $tmp + jq -e ".$key = $value" $tmp > $C_CONFIG_FILE || cp $tmp $C_CONFIG_FILE + rm $tmp + else + jq -en ".$key = $value" > $C_CONFIG_FILE || rm $C_CONFIG_FILE + end +end + set -q XDG_DATA_HOME && set C_DATA $XDG_DATA_HOME/caelestia || set C_DATA $HOME/.local/share/caelestia set -q XDG_STATE_HOME && set C_STATE $XDG_STATE_HOME/caelestia || set C_STATE $HOME/.local/state/caelestia set -q XDG_CACHE_HOME && set C_CACHE $XDG_CACHE_HOME/caelestia || set C_CACHE $HOME/.cache/caelestia set -q XDG_CONFIG_HOME && set CONFIG $XDG_CONFIG_HOME || set CONFIG $HOME/.config +set C_CONFIG $CONFIG/caelestia +set C_CONFIG_FILE $C_CONFIG/scripts.json mkdir -p $C_DATA mkdir -p $C_STATE mkdir -p $C_CACHE +mkdir -p $C_CONFIG |