stow_dotfiles/hyprland/.config/hypr/userScripts/RofiCalc.sh
Matthieu Fortin (CPC/CCP) e281b79c5c hyprland config
2024-09-18 11:56:48 -04:00

31 lines
667 B
Bash
Executable file

#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */
# /* Calculator (using qalculate) and rofi */
# /* Submitted by: https://github.com/JosephArmas */
rofi_config="$HOME/.config/rofi/config-calc.rasi"
# Kill Rofi if already running before execution
if pgrep -x "rofi" >/dev/null; then
pkill rofi
exit 0
fi
# main function
while true; do
result=$(
rofi -i -dmenu \
-config "$rofi_config" \
-mesg "$result = $calc_result"
)
if [ $? -ne 0 ]; then
exit
fi
if [ -n "$result" ]; then
calc_result=$(qalc -t "$result")
echo "$calc_result" | wl-copy
fi
done