Compare commits

...

3 Commits

Author SHA1 Message Date
e4258d8ec1 Install: Add qalc and qalculate 2025-12-04 09:13:37 -08:00
13bade3a4d Rofi: Add qalc command and hotkey 2025-12-04 09:13:25 -08:00
e251e675f4 Rofi: Move copyq script 2025-12-04 09:13:08 -08:00
4 changed files with 77 additions and 2 deletions

View File

@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# https://github.com/onespaceman/menu-calc
# https://github.com/BarbUk/menu-qalc
# https://github.com/ClemaX/menu-qalc-wayland
#
# Calculator for use with rofi
# Copying to the clipboard requires wl-copy
usage() {
echo "$(tput bold)menu-calc$(tput sgr0)"
echo "A calculator for Rofi"
echo
echo "$(tput bold)Usage:$(tput sgr0)"
echo " = 4+2"
echo " = (4+2)/(4+3)"
echo " = 4^2"
echo " = sqrt(4)"
echo " = c(2)"
echo
echo "$(tput bold)Passing arguments to Rofi:$(tput sgr0)"
echo "Any parameters after ' -- ' will be passed to Rofi."
echo
echo " = -- <Rofi args>"
echo
echo "The answer can be copied to the clipboard and used for further calculations inside (or outside) Rofi."
echo
echo "If launched outside of Rofi the expression may need quotation marks."
exit
}
process_query() { # query
local query="$1"
qalc +u8 -color=never -terse <<<"$query" |
awk '!/^>/ && !/^$/ {gsub(/^[ \t]+|[ \t]+$/, "", $0); print}'
}
# Process CLI parameters
for var in "$@"; do
case $var in
-h | --help) usage ;;
--) break ;;
esac
done
# Path to menu application
if [[ -n $(command -v rofi) ]]; then
menu="$(command -v rofi)"
menu="$menu -dmenu -lines 3"
else
>&2 echo "Rofi not found"
exit
fi
# Determine args to pass to rofi
while [[ $# -gt 0 && $1 != "--" ]]; do
shift
done
[[ $1 == "--" ]] && shift
while true; do
action=$(echo -e "Copy\nClear\nClose" | ${menu} "$@" -p "= $answer")
case "$action" in
"Clear") answer= ;;
"Copy") wl-copy -- "$answer" ;;
"Close" | "") exit ;;
*) answer=$(process_query "$answer $action") ;;
esac
done

View File

@@ -77,7 +77,10 @@ input "2362:628:PIXA3854:00_093A:0274_Touchpad" {
bindsym $mod+Tab exec rofi -show window -modes window bindsym $mod+Tab exec rofi -show window -modes window
# Clipboard history # Clipboard history
bindsym $mod+Shift+v exec /home/tgrosinger/.dotfiles/bin/linux/rofi-copyq.sh bindsym $mod+Shift+v exec /home/tgrosinger/.config/rofi/scripts/copyq.sh
# Calculator
bindsym $mod+Equal exec /home/tgrosinger/.config/rofi/scripts/qalc.sh
# Lazygit # Lazygit
bindsym $mod+g exec alacritty --title Floating-Lazygit --command /home/linuxbrew/.linuxbrew/bin/lazygit; grab_focus; floating enable bindsym $mod+g exec alacritty --title Floating-Lazygit --command /home/linuxbrew/.linuxbrew/bin/lazygit; grab_focus; floating enable

View File

@@ -55,7 +55,8 @@ sudo dnf install \
distrobox \ distrobox \
fuse-libs \ # For running appimages fuse-libs \ # For running appimages
gstreamer1-plugin-openh264 mozilla-openh264 \ # For twitch videos gstreamer1-plugin-openh264 mozilla-openh264 \ # For twitch videos
podman podman \
qalculate qalculate-gtk # Homebrew version installs x11 and waylany in brew.
# Install tailscale # Install tailscale
# https://tailscale.com/kb/1511/install-fedora-2 # https://tailscale.com/kb/1511/install-fedora-2