summaryrefslogtreecommitdiff
path: root/scriptlets/die-panel.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scriptlets/die-panel.sh')
-rwxr-xr-xscriptlets/die-panel.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/scriptlets/die-panel.sh b/scriptlets/die-panel.sh
new file mode 100755
index 0000000..f20fc9c
--- /dev/null
+++ b/scriptlets/die-panel.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# Dependencies: bash>=3.2, coreutils, file
+
+# Makes the script more portable
+readonly DIR="$HOME/stuf/customization/"
+
+# Optional icon to display before the text
+# Insert the absolute path of the icon
+# Recommended size is 24x24 px
+declare -r ICON_ARRAY=(
+ "${DIR}/icons/dice/inverted-dice-1.png"
+ "${DIR}/icons/dice/inverted-dice-2.png"
+ "${DIR}/icons/dice/inverted-dice-3.png"
+ "${DIR}/icons/dice/inverted-dice-4.png"
+ "${DIR}/icons/dice/inverted-dice-5.png"
+ "${DIR}/icons/dice/inverted-dice-6.png"
+)
+
+# Compute random die
+DIE=$(( RANDOM % 6 ))
+
+# Panel
+if [[ $(file -b "${ICON_ARRAY[DIE]}") =~ PNG|SVG ]]; then
+ INFO="<img>${ICON_ARRAY[DIE]}</img><click>xfce4-panel --plugin-event=genmon-14:refresh:bool:true</click>"
+fi
+
+# Tooltip
+MORE_INFO="<tool>"
+MORE_INFO+="$(( DIE + 1 ))"
+MORE_INFO+="</tool>"
+
+# Panel Print
+echo -e "${INFO}"
+
+# Tooltip Print
+echo -e "${MORE_INFO}"