You are not logged in.
Hello
i have a question about a genmon script for the xfce4-panel.
There is a fun script with a random dice.
I want to make a little animated button, but in order.
This is my first time edit a script.
This is the original script :
#!/usr/bin/env bash
# Dependencies: bash>=3.2, coreutils, file
# Makes the script more portable
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# 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/others/dice-1.png"
"${DIR}/icons/others/dice-2.png"
"${DIR}/icons/others/dice-3.png"
"${DIR}/icons/others/dice-4.png"
"${DIR}/icons/others/dice-5.png"
"${DIR}/icons/others/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>"
INFO+="<click>app</click>"
else
INFO+="<click>app</click>"
fi
# Tooltip
MORE_INFO="<tool>"
MORE_INFO+="$(( DIE + 1 ))"
MORE_INFO+="</tool>"
# Panel Print
echo -e "${INFO}"
# Tooltip Print
echo -e "${MORE_INFO}"
Thanks
Offline
Hello and welcome.
Thanks for the Sunday morning challenge. How about the following:
Main script (gdie)
#!/usr/bin/env bash
# Dependencies: bash>=3.2, coreutils, file
# Makes the script more portable
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# 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-1.png"
"${DIR}/icons/dice-2.png"
"${DIR}/icons/dice-3.png"
"${DIR}/icons/dice-4.png"
"${DIR}/icons/dice-5.png"
"${DIR}/icons/dice-6.png"
)
# Compute random die
DIE=$(( RANDOM % 6 ))
APP=/home/toz/Downloads/tmp/gdie2
# Panel
if [[ $(file -b "${ICON_ARRAY[DIE]}") =~ PNG|SVG ]]; then
INFO="<img>${ICON_ARRAY[DIE]}</img>"
INFO+="<click>$APP</click>"
else
INFO+="<click>$APP</click>"
fi
# Tooltip
MORE_INFO="<tool>"
MORE_INFO+="$(( DIE + 1 ))"
MORE_INFO+="</tool>"
# Panel Print
echo -e "${INFO}"
# Tooltip Print
echo -e "${MORE_INFO}"
...I added the $APP variable.
Supporting script (gdie2):
#!/usr/bin/env bash
# Dependencies: bash>=3.2, coreutils, file
# Makes the script more portable
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# 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-1.png"
"${DIR}/icons/dice-2.png"
"${DIR}/icons/dice-3.png"
"${DIR}/icons/dice-4.png"
"${DIR}/icons/dice-5.png"
"${DIR}/icons/dice-6.png"
)
for i in {1..6}
do
echo "<img>${DIR}/icons/dice-$i.png</img>"
xfce4-panel --plugin-event=genmon-23:refresh:bool:true
done
exit 0
...this script cycles through the 6 dice making it look like they are spinning. Note: you need to change "genmon-23" to point to the name of your specific genmon instance (hover over the item in the Panel Properties Items tab.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Very nice. That's what i needed. Thanks
cheers.
Offline
[ Generated in 0.012 seconds, 7 queries executed - Memory usage: 530.13 KiB (Peak: 530.98 KiB) ]