Skip to content

Instantly share code, notes, and snippets.

@glitsj16
Last active February 20, 2021 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glitsj16/bb62abf52f084c8a4839f3fdc16bb4f6 to your computer and use it in GitHub Desktop.
Save glitsj16/bb62abf52f084c8a4839f3fdc16bb4f6 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
## Show `baru` (system monitor) output in GNOME Shell panel via `argos`
#+ https://github.com/doums/baru
#+ https://github.com/p-e-w/argos
## IMPORTANT ###########################################
#+ Start this script by placing a symlink to it in the argos config dir,
#+ e.g. `ln -sf "${HOME}/bin/quickie" "${HOME}/.config/argos/baru.l.1s.sh"`.
#+ The created panel item has a `Quit` menu item or you can stop
#+ showing output simply by removing the symlink. This will ALSO
#+ stop `baru`.
######################################################
### Variables
_app="baru"
## Show output on the left side in the GNOME Shell panel (.l) and
#+ refresh every second (.1s). These options are controlled by the
#+ `argos` filename format and can be changed accordingly.
#+ https://github.com/p-e-w/argos#filename-format
_argos_symlink="${HOME}/.config/argos/${_app}.l.1s.sh"
## Where can we find `baru`s output?
#+ Bare in mind that this file will be growing as long as baru is running.
#+ It might be wise to truncate it regularly so it doesn't fill up your disk.
_log="${HOME}/Downloads/${_app}.log"
### Logic
# Start baru
${_app} > "$_log" &
sleep 2
# Get the stats.
_stats="$(tail -n 1 "$_log")"
# Show GNOME Shell panel item (including a `quit` menu).
echo "<small><tt>${_stats}</tt></small>"
echo "---"
echo "Quit | bash='rm -f ${_argos_symlink} > /dev/null 2>&1' terminal=false"
# Stop baru
pkill -f "$_app"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment