mirror of
https://github.com/liclac/ambient
synced 2024-11-21 19:33:08 +00:00
Merge pull request #8 from fenhl/bitbar-config
Allow hiding BitBar plugin when inactive
This commit is contained in:
commit
28b7c9d3bf
2 changed files with 29 additions and 11 deletions
|
@ -84,14 +84,18 @@ end, "$1", 31)
|
|||
|
||||
Remember to add it to your `wibox` list! Search for `mytextclock` with a default configuration.
|
||||
|
||||
### Bitbar
|
||||
### BitBar
|
||||
|
||||
Link `bitbar/ambient.60s.sh` into your Bitbar plugin directory.
|
||||
Link `bitbar/ambient.60s.sh` into your BitBar plugin directory.
|
||||
|
||||
```
|
||||
ln -s $(pwd)/bitbar/ambient.60s.sh ~/.bitbar
|
||||
```
|
||||
|
||||
You can put a file named `bitbar/plugins/ambient.json` in one of [the usual locations](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) (e.g. `~/.config`) to configure the plugin:
|
||||
|
||||
- If `showIfEmpty` is false, the plugin will disappear entirely from your menu bar as long as you're not in a known network. Note that BitBar displays its own menu if none of the plugins are active. (Default: `true`)
|
||||
|
||||
Why `fish`? Why not `bash` or `zsh`?
|
||||
------------------------------------
|
||||
|
||||
|
|
|
@ -2,21 +2,35 @@
|
|||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
PATH="/usr/local/bin:$PATH" # to find Homebrew-installed fish
|
||||
|
||||
# look for config file in XDG config dirs
|
||||
while IFS=: read -d: -r p; do
|
||||
if [ -z "$config_path" ] && [ -r "$p/bitbar/plugins/ambient.json" ]; then
|
||||
config_path="$p/bitbar/plugins/ambient.json"
|
||||
fi
|
||||
done <<<$(printf '%s:\0' "${XDG_CONFIG_HOME:-"${HOME}/.config"}:${XDG_CONFIG_DIRS:-/etc/xdg}")
|
||||
if [ -z "$config_path" ]; then
|
||||
config='{}'
|
||||
else
|
||||
config="$(cat "$config_path")"
|
||||
fi
|
||||
|
||||
WIDGET=$(/usr/local/bin/fish $DIR/../ambient-widgets | tr '\n' ' ')
|
||||
|
||||
if [ -z "$WIDGET" ]; then
|
||||
echo "🚄"
|
||||
else
|
||||
echo $WIDGET
|
||||
echo "---"
|
||||
echo "Go to map|href=https://iceportal.de/karte"
|
||||
echo $(/usr/local/bin/fish $DIR/../ambient | tr '\n' '\r\n')
|
||||
if echo "$config" | jq -e 'if has("showIfEmpty") then .showIfEmpty else true end' > /dev/null; then
|
||||
echo "🚄"
|
||||
fi
|
||||
else
|
||||
echo $WIDGET
|
||||
echo "---"
|
||||
echo "Go to map|href=https://iceportal.de/karte"
|
||||
echo $(/usr/local/bin/fish $DIR/../ambient | tr '\n' '\r\n')
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue