diff --git a/bootstrap/packages.tsv b/bootstrap/packages.tsv index 2dc2f6c..f643881 100644 --- a/bootstrap/packages.tsv +++ b/bootstrap/packages.tsv @@ -249,6 +249,7 @@ toilet free replacement for the FIGlet utility. A tomb Crypto Undertaker, a simple tool to manage encrypted storage R toot a Mastodon CLI client A topgrade Invoke the upgrade procedure of multiple package managers R +translate-shell A command-line interface and interactive shell for Google Translate R transmission-qt Fast, easy, and free BitTorrent client (Qt GUI) R ttf-brill Brill Typeface by John Hudson for Brill Publishing House A ttf-comic-neue Comic Neue aspires to be the casual script choice for everyone including the typographically savvy. A diff --git a/scripts/.local/bin/bemenu-translate b/scripts/.local/bin/bemenu-translate new file mode 100755 index 0000000..13ea606 --- /dev/null +++ b/scripts/.local/bin/bemenu-translate @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# bemenu-translate + +# A very simple bemenu wrapper script for translate-shell. +# +# Displays a bemenu into which user can enter their phrase +# and any options they want to pass to translate-shell. +# Subsequently opens a second prompt with the results. +# If phrase is entered and then Alt+1 instead of Enter pressed +# will show the 'brief', often only one-word single-translation +# results instead. +# +# Some useful commandline options for translate shell are e.g.: +# `de: Wort` -> to translate 'from' German +# `:es horse` -> to translate 'to' Spanish +# and both can be combined as well `de:es Pferd`. +# But of course many more possibilities exist, see +# translate-shell help. + +input=$(echo " " | bemenu -p "Alt+1 for brief mode| Translate>") +exit_code="$?" + +if [ -z "$input" ]; then + exit 0 +fi + +case "$exit_code" in +1) exit 0 ;; +0) + output=$(echo "$input" | xargs trans -j -no-ansi) + ;; +10) + output=$(echo "$input" | xargs trans -j -no-ansi -b) + ;; +esac + +chosen=$(echo "$output" | bemenu -p "Translation:" -w -l 100) + +if [ -n "$chosen" ] && exist clip; then + clip "$chosen" +fi diff --git a/wayland/.config/river/init b/wayland/.config/river/init index 1ab3919..ee0b9cd 100755 --- a/wayland/.config/river/init +++ b/wayland/.config/river/init @@ -59,6 +59,9 @@ riverctl map normal $mod+Shift R spawn "$term --class float -e qalc" # Open emoji picker riverctl map normal $mod+Shift E spawn "bemoji -t" +# Open translation helper +riverctl map normal $mod+Shift T spawn "bemenu-translate" + # Desktop theming # shellcheck disable=SC2016 riverctl map normal $mod+Shift S spawn 'styler set $(styler list themes | bemenu)' @@ -146,20 +149,20 @@ riverctl map normal $mod+Shift Comma send-to-output previous # set up 10 tags (with '0' opening the 10th one) for i in $(seq 0 9); do - tags=$((1 << (i - 1))) - if [ "$i" -eq 0 ]; then tags=$((1 << 9)); fi + tags=$((1 << (i - 1))) + if [ "$i" -eq 0 ]; then tags=$((1 << 9)); fi - # Mod+[1-9] to focus tag [0-8] - riverctl map normal $mod "$i" set-focused-tags $tags + # Mod+[1-9] to focus tag [0-8] + riverctl map normal $mod "$i" set-focused-tags $tags - # Mod+Shift+[1-9] to tag focused view with tag [0-8] - riverctl map normal $mod+Shift "$i" set-view-tags $tags + # Mod+Shift+[1-9] to tag focused view with tag [0-8] + riverctl map normal $mod+Shift "$i" set-view-tags $tags - # Mod+Ctrl+[1-9] to toggle focus of tag [0-8] - riverctl map normal $mod+Control "$i" toggle-focused-tags $tags + # Mod+Ctrl+[1-9] to toggle focus of tag [0-8] + riverctl map normal $mod+Control "$i" toggle-focused-tags $tags - # Mod+Shift+Ctrl+[1-9] to toggle tag [0-8] of focused view - riverctl map normal $mod+Shift+Control "$i" toggle-view-tags $tags + # Mod+Shift+Ctrl+[1-9] to toggle tag [0-8] of focused view + riverctl map normal $mod+Shift+Control "$i" toggle-view-tags $tags done # focus all tags @@ -171,22 +174,22 @@ riverctl map normal $mod+Shift equal set-view-tags $all_tags # Various media key mapping examples for both normal and locked mode which do # not have a modifier for mode in normal locked; do - # Eject the optical drive - riverctl map $mode None XF86Eject spawn 'eject -T' + # Eject the optical drive + riverctl map $mode None XF86Eject spawn 'eject -T' - riverctl map $mode None XF86AudioRaiseVolume spawn 'pactl set-sink-volume @DEFAULT_SINK@ +5%' - riverctl map $mode None XF86AudioLowerVolume spawn 'pactl set-sink-volume @DEFAULT_SINK@ -5%' - riverctl map $mode None XF86AudioMute spawn 'pactl set-sink-mute @DEFAULT_SINK@ toggle' + riverctl map $mode None XF86AudioRaiseVolume spawn 'pactl set-sink-volume @DEFAULT_SINK@ +5%' + riverctl map $mode None XF86AudioLowerVolume spawn 'pactl set-sink-volume @DEFAULT_SINK@ -5%' + riverctl map $mode None XF86AudioMute spawn 'pactl set-sink-mute @DEFAULT_SINK@ toggle' - # Control MPRIS aware media players with playerctl (https://github.com/altdesktop/playerctl) - riverctl map $mode None XF86AudioMedia spawn 'playerctl play-pause' - riverctl map $mode None XF86AudioPlay spawn 'playerctl play-pause' - riverctl map $mode None XF86AudioPrev spawn 'playerctl previous' - riverctl map $mode None XF86AudioNext spawn 'playerctl next' + # Control MPRIS aware media players with playerctl (https://github.com/altdesktop/playerctl) + riverctl map $mode None XF86AudioMedia spawn 'playerctl play-pause' + riverctl map $mode None XF86AudioPlay spawn 'playerctl play-pause' + riverctl map $mode None XF86AudioPrev spawn 'playerctl previous' + riverctl map $mode None XF86AudioNext spawn 'playerctl next' - # You can control screen backlight brighness with light (https://github.com/haikarainen/light); but we prefer brightnessctl - riverctl map $mode None XF86MonBrightnessUp spawn 'brightnessctl set 10%+' - riverctl map $mode None XF86MonBrightnessDown spawn 'brightnessctl set 10%-' + # You can control screen backlight brighness with light (https://github.com/haikarainen/light); but we prefer brightnessctl + riverctl map $mode None XF86MonBrightnessUp spawn 'brightnessctl set 10%+' + riverctl map $mode None XF86MonBrightnessDown spawn 'brightnessctl set 10%-' done # The scratchpad will live on an unused tag. Which tags are used depends on your @@ -210,14 +213,14 @@ riverctl spawn-tagmask ${all_but_scratch_tag} # device (touchscreen) # enable touch clicking for touchpads for pad in $(riverctl list-inputs | grep -i touchpad); do - riverctl input "$pad" events enabled - riverctl input "$pad" tap enabled + riverctl input "$pad" events enabled + riverctl input "$pad" tap enabled done for pad in $(riverctl list-inputs | grep -i touchscreen); do - riverctl input "$pad" events enabled - riverctl input "$pad" tap enabled - riverctl input "$pad" drag enabled - riverctl input "$pad" pointer-accel 0.5 + riverctl input "$pad" events enabled + riverctl input "$pad" tap enabled + riverctl input "$pad" drag enabled + riverctl input "$pad" pointer-accel 0.5 done setxkbmap -option "compose:menu"