dots


dots / config / .local / bin
xxwhirlpool  ·  2026-03-10

temp

 1#!/usr/bin/env bash
 2
 3f_to_c() {
 4	fah="$(gum input --placeholder 'enter temp in fahrenheit')"
 5	cel=$(bc <<< "scale=2; ($fah - 32) * 5/9")
 6	result="$fah°F is equal to $cel°C"
 7	notify-send "$result" && echo "$result"
 8}
 9
10c_to_f() {
11	cel="$(gum input --placeholder 'enter temp in celsius')"
12	fah=$(bc <<< "scale=2; ($cel * 9/5) + 32")
13	result="$cel°C is equal to $fah°F"
14	notify-send "$result" && echo "$result"
15}
16
17choice() {
18	choose=$(gum choose "fahrenheit to celsius" "celsius to fahrenheit")
19	case "$choose" in
20		*celsius) f_to_c ;;
21		*fahrenheit) c_to_f ;;
22		*) exit;;
23	esac
24}
25
26choice