philj56 / tofi

Tiny dynamic menu for Wayland
MIT License
853 stars 36 forks source link

[feature] Tofi as fast calculator #172

Open BoolmanO opened 3 months ago

BoolmanO commented 3 months ago

I think it can be very helpful in some situations, so, maybe add some sort of option for calculator mode? If you don't want this, maybe add mode when tofi can accept output from some script or smth like that?

partisani commented 3 weeks ago

I think the latter is the better option, because by implementing this, (depending on how its done) tofi will be useful for things like getting user input and allow anyone to make a tool that uses it if so desired

DontBlameMe99 commented 1 week ago

This is how I implemented the calculator for myself. It uses tofi as the input and then just copies the result. I hope this can be of use for someone:

# Input operation
operation=$(echo "" | tofi --prompt-text="Math Operation: " --require-match=false)

# Calculate the result
result=$(echo "$operation" | bc -l)

# Copy the result to the clipboard
echo "$result" | wl-copy
notify-send "Result: $result" "The result has been copied to the clipboard."
partisani commented 5 days ago

like, how didn't i think of this before?

anyways, thanks for the tip