dots


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

tempmenu

 1#!/usr/bin/env bash
 2
 3f_to_c() {
 4	fah=$(echo "" | dmenu -i -c -l 3 -p '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"
 8}
 9
10c_to_f() {
11	cel=$(echo "" | dmenu -i -c -l 3 -p '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"
15}
16
17menu() {
18	cmd=$(printf "fahrenheit to celsius\\ncelsius to fahrenheit" | dmenu -i -c -l 10 -p "temperature conversion")
19	case "$cmd" in
20		*celsius) f_to_c ;;
21		*fahrenheit) c_to_f ;;
22		*) exit 0;;
23	esac
24}
25
26case "$1" in
27	*menu) menu ;;
28	*) exit;;
29esac