Compare commits
4 Commits
9d61d9f418
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e4258d8ec1 | |||
| 13bade3a4d | |||
| e251e675f4 | |||
| f3522bf985 |
37
home/.config/rofi/scripts/copyq.sh
Executable file
37
home/.config/rofi/scripts/copyq.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Read the most recent items from CopyQ and present them in a rofi menu.
|
||||
#
|
||||
# Converted to bash from
|
||||
# https://github.com/cjbassi/rofi-copyq/blob/master/rofi-copyq
|
||||
|
||||
# CopyQ script to get all clipboard items as JSON
|
||||
copyq_script_getAll='
|
||||
var result=[];
|
||||
for ( var i = 0; i < size(); ++i ) {
|
||||
var obj = {};
|
||||
obj.row = i;
|
||||
obj.mimetypes = str(read("?", i)).split("\n");
|
||||
obj.mimetypes.pop();
|
||||
obj.text = str(read(i));
|
||||
result.push(obj);
|
||||
}
|
||||
JSON.stringify(result);
|
||||
'
|
||||
|
||||
# Get clipboard items from CopyQ
|
||||
json_arr=$(printf '%s' "$copyq_script_getAll" | copyq -)
|
||||
|
||||
# Parse JSON and format items for rofi
|
||||
# Process each JSON object separately, replacing newlines within each item
|
||||
items=$(printf '%s' "$json_arr" | jq -r '.[] | .text | gsub("\n"; " ") | gsub(" +"; " ")')
|
||||
|
||||
# Show rofi menu and get selected index
|
||||
title='rofi-copyq'
|
||||
selected_index=$(printf '%s' "$items" | rofi -dmenu -i -p "$title" -format i)
|
||||
|
||||
# If user selected an item, select it in CopyQ
|
||||
if [ -n "$selected_index" ]; then
|
||||
echo "Selected item: $selected_index"
|
||||
copyq "select($selected_index);"
|
||||
fi
|
||||
71
home/.config/rofi/scripts/qalc.sh
Executable file
71
home/.config/rofi/scripts/qalc.sh
Executable 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
|
||||
@@ -76,6 +76,12 @@ input "2362:628:PIXA3854:00_093A:0274_Touchpad" {
|
||||
# Window switching
|
||||
bindsym $mod+Tab exec rofi -show window -modes window
|
||||
|
||||
# Clipboard history
|
||||
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
|
||||
bindsym $mod+g exec alacritty --title Floating-Lazygit --command /home/linuxbrew/.linuxbrew/bin/lazygit; grab_focus; floating enable
|
||||
for_window [title="Floating-Lazygit"] floating enable
|
||||
|
||||
@@ -55,7 +55,8 @@ sudo dnf install \
|
||||
distrobox \
|
||||
fuse-libs \ # For running appimages
|
||||
gstreamer1-plugin-openh264 mozilla-openh264 \ # For twitch videos
|
||||
podman
|
||||
podman \
|
||||
qalculate qalculate-gtk # Homebrew version installs x11 and waylany in brew.
|
||||
|
||||
# Install tailscale
|
||||
# https://tailscale.com/kb/1511/install-fedora-2
|
||||
|
||||
Reference in New Issue
Block a user