#!/bin/bash
# Picks the icon of the menu button on the panel: das-panel-icon star|trident|<icon name>.
set -u

case ${1:-} in
star) icon=das-logo ;;
trident) icon=das-trident ;;
"")
  echo "usage: das-panel-icon star|trident|ICON-NAME" >&2
  echo "now: $(xfconf-query -c xfce4-panel -p /plugins/plugin-1/button-icon 2>/dev/null || echo das-logo)" >&2
  exit 1
  ;;
*) icon=$1 ;;
esac

prop=/plugins/plugin-1/button-icon
xfconf-query -c xfce4-panel -p "$prop" -s "$icon" 2>/dev/null ||
  xfconf-query -c xfce4-panel -p "$prop" -n -t string -s "$icon" || exit 1
# whiskermenu keeps its own copy in the rc file, which wins over xfconf
rc="${XDG_CONFIG_HOME:-$HOME/.config}/xfce4/panel/whiskermenu-1.rc"
[[ -f $rc ]] && sed -i "s|^button-icon=.*|button-icon=$icon|" "$rc"
xfce4-panel -r >/dev/null 2>&1 &
