From 17a732446ba4cb34d0b3da8df322c14c78cc87fa Mon Sep 17 00:00:00 2001 From: bh Date: Sat, 7 Mar 2026 18:50:37 +0800 Subject: Clean rofi config --- rofi/.config/rofi/clipboard-launcher-enhanced.sh | 281 --------------------- rofi/.config/rofi/clipboard-launcher.sh | 59 ----- rofi/.config/rofi/clipboard-wayland.sh | 29 --- rofi/.config/rofi/clipboard.rasi | 201 --------------- rofi/.config/rofi/power-profiles.rasi | 122 --------- rofi/.config/rofi/powermenu.rasi | 125 --------- rofi/.config/rofi/rofikeyhint.rasi | 138 ---------- .../rofi/scripts/clipboard-launcher-enhanced.sh | 281 +++++++++++++++++++++ rofi/.config/rofi/scripts/clipboard-launcher.sh | 59 +++++ rofi/.config/rofi/scripts/clipboard-wayland.sh | 29 +++ rofi/.config/rofi/scripts/clipboard.rasi | 201 +++++++++++++++ 11 files changed, 570 insertions(+), 955 deletions(-) delete mode 100755 rofi/.config/rofi/clipboard-launcher-enhanced.sh delete mode 100755 rofi/.config/rofi/clipboard-launcher.sh delete mode 100755 rofi/.config/rofi/clipboard-wayland.sh delete mode 100644 rofi/.config/rofi/clipboard.rasi delete mode 100644 rofi/.config/rofi/power-profiles.rasi delete mode 100644 rofi/.config/rofi/powermenu.rasi delete mode 100644 rofi/.config/rofi/rofikeyhint.rasi create mode 100755 rofi/.config/rofi/scripts/clipboard-launcher-enhanced.sh create mode 100755 rofi/.config/rofi/scripts/clipboard-launcher.sh create mode 100755 rofi/.config/rofi/scripts/clipboard-wayland.sh create mode 100644 rofi/.config/rofi/scripts/clipboard.rasi (limited to 'rofi') diff --git a/rofi/.config/rofi/clipboard-launcher-enhanced.sh b/rofi/.config/rofi/clipboard-launcher-enhanced.sh deleted file mode 100755 index bdee2ec..0000000 --- a/rofi/.config/rofi/clipboard-launcher-enhanced.sh +++ /dev/null @@ -1,281 +0,0 @@ -#!/usr/bin/env bash -#============================================================================== -# Enhanced Greenclip Clipboard Manager with Image Support -#============================================================================== -# This script provides a fully-functional clipboard manager using rofi and -# greenclip, with proper support for both text and images. -# -# Features: -# - Displays clipboard history from greenclip -# - Shows image thumbnails for copied images -# - Truncates long text for readability -# - Properly pastes both text AND images back to clipboard -# - Handles greenclip's image format: "image/png Zen [hash]" -# -# Requirements: -# - rofi (with script mode and thumbnail support) -# - greenclip (clipboard manager daemon must be running) -# - xsel (for clipboard operations - prevents rofi freeze issues) -# - Image files stored in /tmp/greenclip/ (configured in greenclip.toml) -# -# How Greenclip Stores Images: -# 1. Text entries: Stored as-is in clipboard history -# 2. Image entries: Stored as "image/png Zen [hash]" in history -# 3. Actual PNG files: Saved to /tmp/greenclip/[hash].png -# 4. This script: Detects images, shows thumbnails, and restores them properly -#============================================================================== - -# Directory where greenclip caches image files -# IMPORTANT: This must match image_cache_directory in ~/.config/greenclip.toml -IMGDIR="/tmp/greenclip" - -# Maximum text length to display before truncating -MAX_TEXT_LENGTH=100 - -#------------------------------------------------------------------------------ -# clipboard_mode() - Main rofi script mode handler -#------------------------------------------------------------------------------ -# Called by rofi in two contexts: -# -# Context 1: ROFI_RETV=0 (Initial call) -# - Generate the menu items from greenclip history -# - Detect image vs text entries -# - Format with thumbnails and truncation -# - Store original content in info field for later retrieval -# -# Context 2: ROFI_RETV=1 (User selected item) -# - Receive selection via $ROFI_INFO -# - Determine if it's an image or text -# - Copy to clipboard appropriately (file for images, text for text) -#------------------------------------------------------------------------------ -clipboard_mode() { - if [ "$ROFI_RETV" = "0" ]; then - #---------------------------------------------------------------------- - # CONTEXT 1: Generate Menu Items - #---------------------------------------------------------------------- - - # Read clipboard history line by line from greenclip - greenclip print | while IFS= read -r line; do - - #------------------------------------------------------------------ - # IMAGE DETECTION AND DISPLAY - #------------------------------------------------------------------ - # Greenclip outputs image entries in format: "image/png Zen [hash]" - # We need to: - # 1. Detect these entries (starts with "image/") - # 2. Extract the hash/ID - # 3. Find the corresponding PNG file in IMGDIR - # 4. Display with thumbnail icon - #------------------------------------------------------------------ - - if [[ "$line" =~ ^image/png ]]; then - # This is an image entry! - - # Extract the hash from "image/png Zen [hash]" - # The hash is the last field (may be negative number) - hash=$(echo "$line" | awk '{print $NF}') - - # Construct the image file path - # Note: greenclip saves as [hash].png or [-hash].png - imgfile="$IMGDIR/${hash}.png" - - # Check if image file exists - if [ -f "$imgfile" ]; then - # Get just the filename for display - imgname=$(basename "$imgfile") - - # Display format for rofi: - # [display text] \0 icon \x1f [thumbnail path] \0 info \x1f [original line] - # - # Components: - # - Display: "🖼️ Image: filename.png" (what user sees) - # - Icon: thumbnail://path (shows image preview) - # - Info: original greenclip line (used for restoration) - # printf '🖼️ Image: %s\0icon\x1fthumbnail://%s\0info\x1f%s\n' \ - printf '󰋩 IMAGE: %s\0icon\x1fthumbnail://%s\0info\x1f%s\n' \ - "$imgname" \ - "$imgfile" \ - "$line" - else - # Image file not found, show as broken/missing - # Still preserve the original line in case file appears later - # printf '🖼️ Image (missing): %s\0info\x1f%s\n' \ - printf '󰠫 IMAGE (MISSING): %s\0info\x1f%s\n' \ - "$hash" \ - "$line" - fi - - # Done processing this image entry, move to next line - continue - fi - - #------------------------------------------------------------------ - # TEXT ENTRY DISPLAY - #------------------------------------------------------------------ - # For regular text clipboard entries: - # 1. Truncate if too long (for display) - # 2. Preserve full original text in info field (for pasting) - #------------------------------------------------------------------ - - if [ ${#line} -gt $MAX_TEXT_LENGTH ]; then - # Text is long - truncate for display but preserve original - display_text="${line:0:$MAX_TEXT_LENGTH}..." - - # Format: [truncated text] \0 info \x1f [full original text] - # User sees truncated version, but pastes full version - printf '%s\0info\x1f%s\n' "$display_text" "$line" - else - # Text is short - can display as-is - # Still use info field for consistency in selection handling - printf '%s\0info\x1f%s\n' "$line" "$line" - fi - done - - else - #---------------------------------------------------------------------- - # CONTEXT 2: Handle User Selection - #---------------------------------------------------------------------- - # User selected an item. $ROFI_INFO contains the original content - # we stored in the info field during menu generation. - # - # We need to: - # 1. Check if selection is an image or text - # 2. For images: Copy the PNG file to clipboard - # 3. For text: Copy the text to clipboard - #---------------------------------------------------------------------- - - selection="$ROFI_INFO" - - #---------------------------------------------------------------------- - # IMAGE SELECTION HANDLING - #---------------------------------------------------------------------- - # Check if selected item is an image entry (starts with "image/png") - #---------------------------------------------------------------------- - if [[ "$selection" =~ ^image/png ]]; then - # This is an image! Extract hash and copy the actual PNG file - - # Parse hash from "image/png Zen [hash]" - hash=$(echo "$selection" | awk '{print $NF}') - - # Construct image file path - imgfile="$IMGDIR/${hash}.png" - - # Verify image file exists before copying - if [ -f "$imgfile" ]; then - # Copy the actual PNG file to clipboard as image data - # Using xsel instead of xclip to prevent rofi freeze issues - # -b: Use clipboard (equivalent to --clipboard) - # -i: Read from stdin/file - xsel --clipboard --input < "$imgfile" - - # Exit successfully - image is now in clipboard - exit 0 - else - # Image file not found - show error notification if dunstify available - if command -v dunstify &> /dev/null; then - dunstify -u critical "Clipboard Error" "Image file not found: $imgfile" - fi - # Exit with error code - exit 1 - fi - else - #------------------------------------------------------------------ - # TEXT SELECTION HANDLING - #------------------------------------------------------------------ - # This is regular text - copy to clipboard as text - #------------------------------------------------------------------ - - # Copy text directly to clipboard using xsel - # Using xsel instead of xclip to prevent rofi freeze issues - # -b: Use clipboard (equivalent to --clipboard) - # -i: Read from stdin - # Using echo -n to avoid adding newline - echo -n "$selection" | xsel --clipboard --input - - # Exit successfully - text is now in clipboard - exit 0 - fi - fi -} - -#============================================================================== -# Export for rofi script mode -#============================================================================== -# Make function and variables available when rofi spawns this script -export -f clipboard_mode -export IMGDIR -export MAX_TEXT_LENGTH - -#============================================================================== -# MAIN SCRIPT ENTRY POINT -#============================================================================== -# Two execution modes based on ROFI_RETV environment variable: -# -# MODE 1: Direct execution (ROFI_RETV is unset/empty) -# - User ran this script from command line or keybind -# - Launch rofi with this script as the clipboard provider -# - Rofi will then call this script again in MODE 2 -# -# MODE 2: Called by rofi (ROFI_RETV is set) -# - Rofi is calling us to get menu items or handle selection -# - Call clipboard_mode() function to handle the request -#============================================================================== - -if [ -z "$ROFI_RETV" ]; then - #-------------------------------------------------------------------------- - # MODE 1: Launch rofi - #-------------------------------------------------------------------------- - - # Launch rofi with this script as the data source for "clipboard" mode - # - # Rofi parameters: - # -modi "clipboard:$0" - # Register "clipboard" mode that runs this script for data - # - # -show clipboard - # Display the clipboard mode immediately - # - # NO -run-command needed! - # The script handles clipboard copying internally for both text and images - # When user selects an item, rofi calls the script with ROFI_RETV=1 - # The script then copies to clipboard directly and exits - # - # -theme ... - # Custom theme file for visual styling - #-------------------------------------------------------------------------- - - rofi -modi "clipboard:$0" \ - -show clipboard \ - -theme ~/.config/rofi/clipboard.rasi - - # NOTE: All clipboard operations are handled inside clipboard_mode() - # when ROFI_RETV=1 (selection mode). No post-processing needed here. - -else - #-------------------------------------------------------------------------- - # MODE 2: Provide data to rofi or handle selection - #-------------------------------------------------------------------------- - - # Rofi is calling us - hand off to clipboard_mode function - clipboard_mode "$@" -fi - -#============================================================================== -# OLD/ALTERNATIVE APPROACHES (Commented out for reference) -#============================================================================== -# -# APPROACH 1: Using -run-command with xclip for text -# This was the old approach that didn't handle images properly: -# -# rofi -modi "clipboard:$0" \ -# -show clipboard \ -# -run-command 'echo -n {cmd} | xclip -selection clipboard' \ -# -theme ~/.config/rofi/clipboard.rasi -# -# PROBLEM: This pipes ALL selections (including "image/png Zen [hash]" text) -# to xclip as text, which doesn't restore the actual image to clipboard. -# -# SOLUTION: Handle image copying inside the script, before rofi's -run-command, -# by detecting image format and using xclip with -t image/png and the file. -# -#============================================================================== diff --git a/rofi/.config/rofi/clipboard-launcher.sh b/rofi/.config/rofi/clipboard-launcher.sh deleted file mode 100755 index c223fe9..0000000 --- a/rofi/.config/rofi/clipboard-launcher.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash -#============================================================================== -# Ultra-Simple Text-Only Clipboard Launcher -#============================================================================== -# NO images, NO thumbnails, NO script mode - just text clipboard -# This is the absolute simplest version that should never crash -#============================================================================== - -# Simple one-liner: show greenclip history, copy selection to clipboard -# -p "" sets the prompt with clipboard icon -greenclip print | rofi -dmenu -i -p "" -theme ~/.config/rofi/clipboard.rasi | xclip -selection clipboard - -#============================================================================== -# OLD COMPLEX VERSIONS (commented out - they caused crashes) -#============================================================================== - -# VERSION WITH SCRIPT MODE (was crashing): -# IMGDIR="/tmp/greenclip" -# -# clipboard_mode() { -# if [ "$ROFI_RETV" = "0" ]; then -# greenclip print | while IFS= read -r line; do -# if [[ "$line" =~ ^image/png ]]; then -# hash=$(echo "$line" | awk '{print $NF}') -# imgfile="$IMGDIR/${hash}.png" -# if [ -f "$imgfile" ]; then -# printf '[IMAGE] %s\0info\x1f%s\n' "$(basename "$imgfile")" "$line" -# fi -# else -# printf '%s\0info\x1f%s\n' "$line" "$line" -# fi -# done -# else -# selection="$ROFI_INFO" -# [ -z "$selection" ] && exit 0 -# if [[ "$selection" =~ ^image/png ]]; then -# hash=$(echo "$selection" | awk '{print $NF}') -# imgfile="$IMGDIR/${hash}.png" -# if [ -f "$imgfile" ] && [ -r "$imgfile" ]; then -# xclip -selection clipboard -t image/png -i "$imgfile" 2>/dev/null -# fi -# else -# echo -n "$selection" | xclip -selection clipboard 2>/dev/null -# fi -# exit 0 -# fi -# } -# -# export -f clipboard_mode -# export IMGDIR -# -# if [ -z "$ROFI_RETV" ]; then -# rofi -modi "clipboard:$0" -show clipboard -theme ~/.config/rofi/clipboard.rasi -# else -# clipboard_mode "$@" -# fi - -# VERSION WITH THUMBNAILS (crashed even more): -# [See backup files for reference] diff --git a/rofi/.config/rofi/clipboard-wayland.sh b/rofi/.config/rofi/clipboard-wayland.sh deleted file mode 100755 index 93789a0..0000000 --- a/rofi/.config/rofi/clipboard-wayland.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -clipboard_mode() { - if [ "$ROFI_RETV" = "0" ]; then - cliphist list | while IFS= read -r line; do - id="${line%% *}" - content="${line#* }" - - if [[ "$content" == *"[[ binary data"* ]]; then - printf '󰋩 IMAGE: %s\0info\x1f%s\n' "$id" "$id" - else - printf '%s\0info\x1f%s\n' "$content" "$id" - fi - done - else - cliphist decode "$ROFI_INFO" | wl-copy - exit 0 - fi -} - -export -f clipboard_mode - -if [ -z "$ROFI_RETV" ]; then - rofi -modi "clipboard:$0" \ - -show clipboard \ - -theme ~/.config/rofi/clipboard.rasi -else - clipboard_mode "$@" -fi diff --git a/rofi/.config/rofi/clipboard.rasi b/rofi/.config/rofi/clipboard.rasi deleted file mode 100644 index 6ec4a1b..0000000 --- a/rofi/.config/rofi/clipboard.rasi +++ /dev/null @@ -1,201 +0,0 @@ -/******************************************************* - * CLIPBOARD MANAGER - With Images - *******************************************************/ -/* - * Clipboard theme with nice padding and image support - * - Normal font (10pt) - * - Comfortable padding (like rofidmenu) - * - Icons and images enabled - * - Clean and simple - */ - -configuration { - font: "Noto Sans Nerd Font 10"; - show-icons: true; /* Enable icons for images */ - icon-theme: "Qogir"; - display-clipboard: ""; /* Clipboard icon restored */ - disable-history: false; - sidebar-mode: false; - kb-cancel: "Super+c,Escape"; -} - -/* Import base theme */ -@import "~/.config/rofi/config.rasi" - -/* Window - comfortable padding like rofidmenu */ -window { - background-color: @background; - border: 0; - padding: 30; /* Nice padding like rofidmenu */ - width: 50%; -} - -mainbox { - border: 0; - padding: 0; -} - -/* List view - compact vertical spacing */ -listview { - lines: 10; /* Show 10 entries */ - columns: 1; - fixed-height: 0; - border: 8px 0px 0px; /* Like rofidmenu */ - border-color: @separatorcolor; - scrollbar: true; - padding: 2px 0px 0px; - spacing: 0px; /* Reduced: was 4px, now 2px */ -} - -/* Element - minimal height (no vertical padding) */ -element { - border: 0; - padding: -1px 3px; /* No vertical padding: 0px top/bottom, 3px left/right, negative if you want it to be thin */ -} - -/* Icon configuration for images */ -element-icon { - size: 2em; /* Good size for image thumbnails */ - padding: 0 6px 0 0; /* Space between icon and text */ -} - -element-text { - background-color: inherit; - text-color: inherit; - vertical-align: 0.5; -} - -/* Element states */ -element.normal.normal { - background-color: @normal-background; - text-color: @normal-foreground; -} - -element.selected.normal { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} - -element.alternate.normal { - background-color: @alternate-normal-background; - text-color: @alternate-normal-foreground; -} - -element.normal.urgent { - background-color: @urgent-background; - text-color: @urgent-foreground; -} - -element.selected.urgent { - background-color: @selected-urgent-background; - text-color: @selected-urgent-foreground; -} - -element.alternate.urgent { - background-color: @alternate-urgent-background; - text-color: @alternate-urgent-foreground; -} - -element.normal.active { - background-color: @active-background; - text-color: @active-foreground; -} - -element.selected.active { - background-color: @selected-active-background; - text-color: @selected-active-foreground; -} - -element.alternate.active { - background-color: @alternate-active-background; - text-color: @alternate-active-foreground; -} - -/* Scrollbar */ -scrollbar { - width: 4px; /* Like rofidmenu */ - border: 0; - handle-color: @normal-foreground; - handle-width: 8px; - padding: 0; -} - -/* Input bar */ -inputbar { - spacing: 0; - text-color: @normal-foreground; - padding: 1px; - children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; -} - -prompt { - spacing: 0; - text-color: @normal-foreground; -} - -textbox-prompt-colon { - expand: false; - str: ""; - margin: 0px 0.3em 0em 0em; - text-color: @normal-foreground; -} - -entry { - spacing: 0; - text-color: @normal-foreground; -} - -case-indicator { - spacing: 0; - text-color: @normal-foreground; -} - -message { - border: 2px 0px 0px; - border-color: @separatorcolor; - padding: 1px; -} - -textbox { - text-color: @foreground; -} - -mode-switcher { - border: 2px 0px 0px; - border-color: @separatorcolor; -} - -button { - spacing: 0; - text-color: @normal-foreground; -} - -button.selected { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} - -/*------------------------------------------------------- - * PREVIOUS CONFIGURATIONS (commented for reference) - *------------------------------------------------------- - * - * Ultra-compact version had: - * - Font: 8pt - * - Window padding: 10px - * - List lines: 12 - * - Element padding: 1px vertical - * - Spacing: 1px - * - Icons: disabled - * - * Comfortable version had: - * - Element padding: 3px all sides - * - Spacing: 4px - * - * Current version (compact vertical): - * - Font: 10pt - * - Window padding: 30px (like rofidmenu) - * - List lines: 10 - * - Element padding: 1px vertical, 3px horizontal - * - Spacing: 2px (smaller vertical gaps) - * - Icons: enabled for images - */ diff --git a/rofi/.config/rofi/power-profiles.rasi b/rofi/.config/rofi/power-profiles.rasi deleted file mode 100644 index f7c7755..0000000 --- a/rofi/.config/rofi/power-profiles.rasi +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************* - * ROFI configs i3 powermenu for EndeavourOS - * Maintainer: joekamprad [joekamprad //a_t// endeavouros.com] - *******************************************************/ -configuration { - font: "Noto Sans Regular 10"; - show-icons: false; - icon-theme: "Qogir"; - scroll-method: 0; - disable-history: false; - fullscreen: false; - hide-scrollbar: true; - sidebar-mode: false; -} - -@import "~/.config/rofi/config.rasi" -/* Insert theme modifications after this */ - - -window { - background-color: @background; - border: 0; - padding: 10; - transparency: "real"; - width: 170px; - location: east; - /*y-offset: 18;*/ - /*x-offset: 850;*/ -} -listview { - lines: 4; - columns: 1; -} -element { - border: 0; - padding: 1px; -} -element-text { - background-color: inherit; - text-color: inherit; -} -element.normal.normal { - background-color: @normal-background; - text-color: @normal-foreground; -} -element.normal.urgent { - background-color: @urgent-background; - text-color: @urgent-foreground; -} -element.normal.active { - background-color: @active-background; - text-color: @active-foreground; -} -element.selected.normal { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} -element.selected.urgent { - background-color: @selected-urgent-background; - text-color: @selected-urgent-foreground; -} -element.selected.active { - background-color: @selected-active-background; - text-color: @selected-active-foreground; -} -element.alternate.normal { - background-color: @alternate-normal-background; - text-color: @alternate-normal-foreground; -} -element.alternate.urgent { - background-color: @alternate-urgent-background; - text-color: @alternate-urgent-foreground; -} -element.alternate.active { - background-color: @alternate-active-background; - text-color: @alternate-active-foreground; -} -scrollbar { - width: 4px; - border: 0; - handle-color: @normal-foreground; - handle-width: 8px; - padding: 0; -} -mode-switcher { - border: 2px 0px 0px; - border-color: @separatorcolor; -} -button { - spacing: 0; - text-color: @normal-foreground; -} -button.selected { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} -inputbar { - spacing: 0; - text-color: @normal-foreground; - padding: 1px; -} -case-indicator { - spacing: 0; - text-color: @normal-foreground; -} -entry { - spacing: 0; - text-color: @normal-foreground; -} -prompt { - spacing: 0; - text-color: @normal-foreground; -} -inputbar { - children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; -} -textbox-prompt-colon { - expand: false; - str: "Set Power Profile:"; - margin: 0px 0.3em 0em 0em; - text-color: @normal-foreground; -} diff --git a/rofi/.config/rofi/powermenu.rasi b/rofi/.config/rofi/powermenu.rasi deleted file mode 100644 index 8470a69..0000000 --- a/rofi/.config/rofi/powermenu.rasi +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************* - * ROFI configs i3 powermenu for EndeavourOS - * Maintainer: joekamprad [joekamprad //a_t// endeavouros.com] - *******************************************************/ -configuration { - font: "Noto Sans Regular 10"; - show-icons: false; - icon-theme: "Qogir"; - scroll-method: 0; - disable-history: false; - sidebar-mode: false; -} - -@import "~/.config/rofi/config.rasi" -/* Insert theme modifications after this */ - -window { - background-color: @background; - border: 0; - padding: 10; - transparency: "real"; - width: 120px; - location: east; - /*y-offset: 18;*/ - /*x-offset: 850;*/ -} -listview { - lines: 7; - columns: 1; - scrollbar: false; -} -element { - border: 0; - padding: 1px; -} -element-text { - background-color: inherit; - text-color: inherit; -} -element.normal.normal { - background-color: @normal-background; - text-color: @normal-foreground; -} -element.normal.urgent { - background-color: @urgent-background; - text-color: @urgent-foreground; -} -element.normal.active { - background-color: @active-background; - text-color: @active-foreground; -} -element.selected.normal { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} -element.selected.urgent { - background-color: @selected-urgent-background; - text-color: @selected-urgent-foreground; -} -element.selected.active { - background-color: @selected-active-background; - text-color: @selected-active-foreground; -} -element.alternate.normal { - background-color: @alternate-normal-background; - text-color: @alternate-normal-foreground; -} -element.alternate.urgent { - background-color: @alternate-urgent-background; - text-color: @alternate-urgent-foreground; -} -element.alternate.active { - background-color: @alternate-active-background; - text-color: @alternate-active-foreground; -} -scrollbar { - width: 4px; - border: 0; - handle-color: @normal-foreground; - handle-width: 8px; - padding: 0; -} -mode-switcher { - border: 2px 0px 0px; - border-color: @separatorcolor; -} -button { - spacing: 0; - text-color: @normal-foreground; -} -button.selected { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} -inputbar { - spacing: 0; - text-color: @normal-foreground; - padding: 1px; -} -case-indicator { - spacing: 0; - text-color: @normal-foreground; -} -entry { - spacing: 0; - text-color: @normal-foreground; -} -prompt { - spacing: 0; - text-color: @normal-foreground; -} -inputbar { - children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; -} -textbox-prompt-colon { - expand: false; - str: ":"; - margin: 0px 0.3em 0em 0em; - text-color: @normal-foreground; -} - -/*removes the text input line*/ -mainbox { - children: [listview]; -} diff --git a/rofi/.config/rofi/rofikeyhint.rasi b/rofi/.config/rofi/rofikeyhint.rasi deleted file mode 100644 index 9f9805a..0000000 --- a/rofi/.config/rofi/rofikeyhint.rasi +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************* - * ROFI configs i3 keyhint-menu for EndeavourOS - * Maintainer: joekamprad [joekamprad //a_t// endeavouros.com] - *******************************************************/ -configuration { - font: "Noto Sans Regular 10"; - show-icons: false; - icon-theme: "Qogir"; - display-drun: "KeyHint"; - drun-display-format: "{name}"; - scroll-method: 0; - disable-history: false; - fullscreen: false; - hide-scrollbar: true; - sidebar-mode: false; -} - -@import "~/.config/rofi/config.rasi" -/* Insert theme modifications after this */ - -window { - background-color: @background; - border: 0; - padding: 30; -} -listview { - lines: 10; - columns: 1; -} -mainbox { - border: 0; - padding: 0; -} -message { - border: 2px 0px 0px; - border-color: @separatorcolor; - padding: 1px; -} -textbox { - text-color: @foreground; -} -listview { - fixed-height: 0; - border: 8px 0px 0px; - border-color: @separatorcolor; - spacing: 8px; - scrollbar: false; - padding: 2px 0px 0px; -} -element { - border: 0; - padding: 1px; -} -element-text { - background-color: inherit; - text-color: inherit; -} -element.normal.normal { - background-color: @normal-background; - text-color: @normal-foreground; -} -element.normal.urgent { - background-color: @urgent-background; - text-color: @urgent-foreground; -} -element.normal.active { - background-color: @active-background; - text-color: @active-foreground; -} -element.selected.normal { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} -element.selected.urgent { - background-color: @selected-urgent-background; - text-color: @selected-urgent-foreground; -} -element.selected.active { - background-color: @selected-active-background; - text-color: @selected-active-foreground; -} -element.alternate.normal { - background-color: @alternate-normal-background; - text-color: @alternate-normal-foreground; -} -element.alternate.urgent { - background-color: @alternate-urgent-background; - text-color: @alternate-urgent-foreground; -} -element.alternate.active { - background-color: @alternate-active-background; - text-color: @alternate-active-foreground; -} -scrollbar { - width: 4px; - border: 0; - handle-color: @normal-foreground; - handle-width: 8px; - padding: 0; -} -mode-switcher { - border: 2px 0px 0px; - border-color: @separatorcolor; -} -button { - spacing: 0; - text-color: @normal-foreground; -} -button.selected { - background-color: @selected-normal-background; - text-color: @selected-normal-foreground; -} -inputbar { - spacing: 0; - text-color: @normal-foreground; - padding: 1px; -} -case-indicator { - spacing: 0; - text-color: @normal-foreground; -} -entry { - spacing: 0; - text-color: @normal-foreground; -} -prompt { - spacing: 0; - text-color: @normal-foreground; -} -inputbar { - children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; -} -textbox-prompt-colon { - expand: false; - str: ":"; - margin: 0px 0.3em 0em 0em; - text-color: @normal-foreground; -} diff --git a/rofi/.config/rofi/scripts/clipboard-launcher-enhanced.sh b/rofi/.config/rofi/scripts/clipboard-launcher-enhanced.sh new file mode 100755 index 0000000..bdee2ec --- /dev/null +++ b/rofi/.config/rofi/scripts/clipboard-launcher-enhanced.sh @@ -0,0 +1,281 @@ +#!/usr/bin/env bash +#============================================================================== +# Enhanced Greenclip Clipboard Manager with Image Support +#============================================================================== +# This script provides a fully-functional clipboard manager using rofi and +# greenclip, with proper support for both text and images. +# +# Features: +# - Displays clipboard history from greenclip +# - Shows image thumbnails for copied images +# - Truncates long text for readability +# - Properly pastes both text AND images back to clipboard +# - Handles greenclip's image format: "image/png Zen [hash]" +# +# Requirements: +# - rofi (with script mode and thumbnail support) +# - greenclip (clipboard manager daemon must be running) +# - xsel (for clipboard operations - prevents rofi freeze issues) +# - Image files stored in /tmp/greenclip/ (configured in greenclip.toml) +# +# How Greenclip Stores Images: +# 1. Text entries: Stored as-is in clipboard history +# 2. Image entries: Stored as "image/png Zen [hash]" in history +# 3. Actual PNG files: Saved to /tmp/greenclip/[hash].png +# 4. This script: Detects images, shows thumbnails, and restores them properly +#============================================================================== + +# Directory where greenclip caches image files +# IMPORTANT: This must match image_cache_directory in ~/.config/greenclip.toml +IMGDIR="/tmp/greenclip" + +# Maximum text length to display before truncating +MAX_TEXT_LENGTH=100 + +#------------------------------------------------------------------------------ +# clipboard_mode() - Main rofi script mode handler +#------------------------------------------------------------------------------ +# Called by rofi in two contexts: +# +# Context 1: ROFI_RETV=0 (Initial call) +# - Generate the menu items from greenclip history +# - Detect image vs text entries +# - Format with thumbnails and truncation +# - Store original content in info field for later retrieval +# +# Context 2: ROFI_RETV=1 (User selected item) +# - Receive selection via $ROFI_INFO +# - Determine if it's an image or text +# - Copy to clipboard appropriately (file for images, text for text) +#------------------------------------------------------------------------------ +clipboard_mode() { + if [ "$ROFI_RETV" = "0" ]; then + #---------------------------------------------------------------------- + # CONTEXT 1: Generate Menu Items + #---------------------------------------------------------------------- + + # Read clipboard history line by line from greenclip + greenclip print | while IFS= read -r line; do + + #------------------------------------------------------------------ + # IMAGE DETECTION AND DISPLAY + #------------------------------------------------------------------ + # Greenclip outputs image entries in format: "image/png Zen [hash]" + # We need to: + # 1. Detect these entries (starts with "image/") + # 2. Extract the hash/ID + # 3. Find the corresponding PNG file in IMGDIR + # 4. Display with thumbnail icon + #------------------------------------------------------------------ + + if [[ "$line" =~ ^image/png ]]; then + # This is an image entry! + + # Extract the hash from "image/png Zen [hash]" + # The hash is the last field (may be negative number) + hash=$(echo "$line" | awk '{print $NF}') + + # Construct the image file path + # Note: greenclip saves as [hash].png or [-hash].png + imgfile="$IMGDIR/${hash}.png" + + # Check if image file exists + if [ -f "$imgfile" ]; then + # Get just the filename for display + imgname=$(basename "$imgfile") + + # Display format for rofi: + # [display text] \0 icon \x1f [thumbnail path] \0 info \x1f [original line] + # + # Components: + # - Display: "🖼️ Image: filename.png" (what user sees) + # - Icon: thumbnail://path (shows image preview) + # - Info: original greenclip line (used for restoration) + # printf '🖼️ Image: %s\0icon\x1fthumbnail://%s\0info\x1f%s\n' \ + printf '󰋩 IMAGE: %s\0icon\x1fthumbnail://%s\0info\x1f%s\n' \ + "$imgname" \ + "$imgfile" \ + "$line" + else + # Image file not found, show as broken/missing + # Still preserve the original line in case file appears later + # printf '🖼️ Image (missing): %s\0info\x1f%s\n' \ + printf '󰠫 IMAGE (MISSING): %s\0info\x1f%s\n' \ + "$hash" \ + "$line" + fi + + # Done processing this image entry, move to next line + continue + fi + + #------------------------------------------------------------------ + # TEXT ENTRY DISPLAY + #------------------------------------------------------------------ + # For regular text clipboard entries: + # 1. Truncate if too long (for display) + # 2. Preserve full original text in info field (for pasting) + #------------------------------------------------------------------ + + if [ ${#line} -gt $MAX_TEXT_LENGTH ]; then + # Text is long - truncate for display but preserve original + display_text="${line:0:$MAX_TEXT_LENGTH}..." + + # Format: [truncated text] \0 info \x1f [full original text] + # User sees truncated version, but pastes full version + printf '%s\0info\x1f%s\n' "$display_text" "$line" + else + # Text is short - can display as-is + # Still use info field for consistency in selection handling + printf '%s\0info\x1f%s\n' "$line" "$line" + fi + done + + else + #---------------------------------------------------------------------- + # CONTEXT 2: Handle User Selection + #---------------------------------------------------------------------- + # User selected an item. $ROFI_INFO contains the original content + # we stored in the info field during menu generation. + # + # We need to: + # 1. Check if selection is an image or text + # 2. For images: Copy the PNG file to clipboard + # 3. For text: Copy the text to clipboard + #---------------------------------------------------------------------- + + selection="$ROFI_INFO" + + #---------------------------------------------------------------------- + # IMAGE SELECTION HANDLING + #---------------------------------------------------------------------- + # Check if selected item is an image entry (starts with "image/png") + #---------------------------------------------------------------------- + if [[ "$selection" =~ ^image/png ]]; then + # This is an image! Extract hash and copy the actual PNG file + + # Parse hash from "image/png Zen [hash]" + hash=$(echo "$selection" | awk '{print $NF}') + + # Construct image file path + imgfile="$IMGDIR/${hash}.png" + + # Verify image file exists before copying + if [ -f "$imgfile" ]; then + # Copy the actual PNG file to clipboard as image data + # Using xsel instead of xclip to prevent rofi freeze issues + # -b: Use clipboard (equivalent to --clipboard) + # -i: Read from stdin/file + xsel --clipboard --input < "$imgfile" + + # Exit successfully - image is now in clipboard + exit 0 + else + # Image file not found - show error notification if dunstify available + if command -v dunstify &> /dev/null; then + dunstify -u critical "Clipboard Error" "Image file not found: $imgfile" + fi + # Exit with error code + exit 1 + fi + else + #------------------------------------------------------------------ + # TEXT SELECTION HANDLING + #------------------------------------------------------------------ + # This is regular text - copy to clipboard as text + #------------------------------------------------------------------ + + # Copy text directly to clipboard using xsel + # Using xsel instead of xclip to prevent rofi freeze issues + # -b: Use clipboard (equivalent to --clipboard) + # -i: Read from stdin + # Using echo -n to avoid adding newline + echo -n "$selection" | xsel --clipboard --input + + # Exit successfully - text is now in clipboard + exit 0 + fi + fi +} + +#============================================================================== +# Export for rofi script mode +#============================================================================== +# Make function and variables available when rofi spawns this script +export -f clipboard_mode +export IMGDIR +export MAX_TEXT_LENGTH + +#============================================================================== +# MAIN SCRIPT ENTRY POINT +#============================================================================== +# Two execution modes based on ROFI_RETV environment variable: +# +# MODE 1: Direct execution (ROFI_RETV is unset/empty) +# - User ran this script from command line or keybind +# - Launch rofi with this script as the clipboard provider +# - Rofi will then call this script again in MODE 2 +# +# MODE 2: Called by rofi (ROFI_RETV is set) +# - Rofi is calling us to get menu items or handle selection +# - Call clipboard_mode() function to handle the request +#============================================================================== + +if [ -z "$ROFI_RETV" ]; then + #-------------------------------------------------------------------------- + # MODE 1: Launch rofi + #-------------------------------------------------------------------------- + + # Launch rofi with this script as the data source for "clipboard" mode + # + # Rofi parameters: + # -modi "clipboard:$0" + # Register "clipboard" mode that runs this script for data + # + # -show clipboard + # Display the clipboard mode immediately + # + # NO -run-command needed! + # The script handles clipboard copying internally for both text and images + # When user selects an item, rofi calls the script with ROFI_RETV=1 + # The script then copies to clipboard directly and exits + # + # -theme ... + # Custom theme file for visual styling + #-------------------------------------------------------------------------- + + rofi -modi "clipboard:$0" \ + -show clipboard \ + -theme ~/.config/rofi/clipboard.rasi + + # NOTE: All clipboard operations are handled inside clipboard_mode() + # when ROFI_RETV=1 (selection mode). No post-processing needed here. + +else + #-------------------------------------------------------------------------- + # MODE 2: Provide data to rofi or handle selection + #-------------------------------------------------------------------------- + + # Rofi is calling us - hand off to clipboard_mode function + clipboard_mode "$@" +fi + +#============================================================================== +# OLD/ALTERNATIVE APPROACHES (Commented out for reference) +#============================================================================== +# +# APPROACH 1: Using -run-command with xclip for text +# This was the old approach that didn't handle images properly: +# +# rofi -modi "clipboard:$0" \ +# -show clipboard \ +# -run-command 'echo -n {cmd} | xclip -selection clipboard' \ +# -theme ~/.config/rofi/clipboard.rasi +# +# PROBLEM: This pipes ALL selections (including "image/png Zen [hash]" text) +# to xclip as text, which doesn't restore the actual image to clipboard. +# +# SOLUTION: Handle image copying inside the script, before rofi's -run-command, +# by detecting image format and using xclip with -t image/png and the file. +# +#============================================================================== diff --git a/rofi/.config/rofi/scripts/clipboard-launcher.sh b/rofi/.config/rofi/scripts/clipboard-launcher.sh new file mode 100755 index 0000000..c223fe9 --- /dev/null +++ b/rofi/.config/rofi/scripts/clipboard-launcher.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +#============================================================================== +# Ultra-Simple Text-Only Clipboard Launcher +#============================================================================== +# NO images, NO thumbnails, NO script mode - just text clipboard +# This is the absolute simplest version that should never crash +#============================================================================== + +# Simple one-liner: show greenclip history, copy selection to clipboard +# -p "" sets the prompt with clipboard icon +greenclip print | rofi -dmenu -i -p "" -theme ~/.config/rofi/clipboard.rasi | xclip -selection clipboard + +#============================================================================== +# OLD COMPLEX VERSIONS (commented out - they caused crashes) +#============================================================================== + +# VERSION WITH SCRIPT MODE (was crashing): +# IMGDIR="/tmp/greenclip" +# +# clipboard_mode() { +# if [ "$ROFI_RETV" = "0" ]; then +# greenclip print | while IFS= read -r line; do +# if [[ "$line" =~ ^image/png ]]; then +# hash=$(echo "$line" | awk '{print $NF}') +# imgfile="$IMGDIR/${hash}.png" +# if [ -f "$imgfile" ]; then +# printf '[IMAGE] %s\0info\x1f%s\n' "$(basename "$imgfile")" "$line" +# fi +# else +# printf '%s\0info\x1f%s\n' "$line" "$line" +# fi +# done +# else +# selection="$ROFI_INFO" +# [ -z "$selection" ] && exit 0 +# if [[ "$selection" =~ ^image/png ]]; then +# hash=$(echo "$selection" | awk '{print $NF}') +# imgfile="$IMGDIR/${hash}.png" +# if [ -f "$imgfile" ] && [ -r "$imgfile" ]; then +# xclip -selection clipboard -t image/png -i "$imgfile" 2>/dev/null +# fi +# else +# echo -n "$selection" | xclip -selection clipboard 2>/dev/null +# fi +# exit 0 +# fi +# } +# +# export -f clipboard_mode +# export IMGDIR +# +# if [ -z "$ROFI_RETV" ]; then +# rofi -modi "clipboard:$0" -show clipboard -theme ~/.config/rofi/clipboard.rasi +# else +# clipboard_mode "$@" +# fi + +# VERSION WITH THUMBNAILS (crashed even more): +# [See backup files for reference] diff --git a/rofi/.config/rofi/scripts/clipboard-wayland.sh b/rofi/.config/rofi/scripts/clipboard-wayland.sh new file mode 100755 index 0000000..93789a0 --- /dev/null +++ b/rofi/.config/rofi/scripts/clipboard-wayland.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +clipboard_mode() { + if [ "$ROFI_RETV" = "0" ]; then + cliphist list | while IFS= read -r line; do + id="${line%% *}" + content="${line#* }" + + if [[ "$content" == *"[[ binary data"* ]]; then + printf '󰋩 IMAGE: %s\0info\x1f%s\n' "$id" "$id" + else + printf '%s\0info\x1f%s\n' "$content" "$id" + fi + done + else + cliphist decode "$ROFI_INFO" | wl-copy + exit 0 + fi +} + +export -f clipboard_mode + +if [ -z "$ROFI_RETV" ]; then + rofi -modi "clipboard:$0" \ + -show clipboard \ + -theme ~/.config/rofi/clipboard.rasi +else + clipboard_mode "$@" +fi diff --git a/rofi/.config/rofi/scripts/clipboard.rasi b/rofi/.config/rofi/scripts/clipboard.rasi new file mode 100644 index 0000000..6ec4a1b --- /dev/null +++ b/rofi/.config/rofi/scripts/clipboard.rasi @@ -0,0 +1,201 @@ +/******************************************************* + * CLIPBOARD MANAGER - With Images + *******************************************************/ +/* + * Clipboard theme with nice padding and image support + * - Normal font (10pt) + * - Comfortable padding (like rofidmenu) + * - Icons and images enabled + * - Clean and simple + */ + +configuration { + font: "Noto Sans Nerd Font 10"; + show-icons: true; /* Enable icons for images */ + icon-theme: "Qogir"; + display-clipboard: ""; /* Clipboard icon restored */ + disable-history: false; + sidebar-mode: false; + kb-cancel: "Super+c,Escape"; +} + +/* Import base theme */ +@import "~/.config/rofi/config.rasi" + +/* Window - comfortable padding like rofidmenu */ +window { + background-color: @background; + border: 0; + padding: 30; /* Nice padding like rofidmenu */ + width: 50%; +} + +mainbox { + border: 0; + padding: 0; +} + +/* List view - compact vertical spacing */ +listview { + lines: 10; /* Show 10 entries */ + columns: 1; + fixed-height: 0; + border: 8px 0px 0px; /* Like rofidmenu */ + border-color: @separatorcolor; + scrollbar: true; + padding: 2px 0px 0px; + spacing: 0px; /* Reduced: was 4px, now 2px */ +} + +/* Element - minimal height (no vertical padding) */ +element { + border: 0; + padding: -1px 3px; /* No vertical padding: 0px top/bottom, 3px left/right, negative if you want it to be thin */ +} + +/* Icon configuration for images */ +element-icon { + size: 2em; /* Good size for image thumbnails */ + padding: 0 6px 0 0; /* Space between icon and text */ +} + +element-text { + background-color: inherit; + text-color: inherit; + vertical-align: 0.5; +} + +/* Element states */ +element.normal.normal { + background-color: @normal-background; + text-color: @normal-foreground; +} + +element.selected.normal { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} + +element.alternate.normal { + background-color: @alternate-normal-background; + text-color: @alternate-normal-foreground; +} + +element.normal.urgent { + background-color: @urgent-background; + text-color: @urgent-foreground; +} + +element.selected.urgent { + background-color: @selected-urgent-background; + text-color: @selected-urgent-foreground; +} + +element.alternate.urgent { + background-color: @alternate-urgent-background; + text-color: @alternate-urgent-foreground; +} + +element.normal.active { + background-color: @active-background; + text-color: @active-foreground; +} + +element.selected.active { + background-color: @selected-active-background; + text-color: @selected-active-foreground; +} + +element.alternate.active { + background-color: @alternate-active-background; + text-color: @alternate-active-foreground; +} + +/* Scrollbar */ +scrollbar { + width: 4px; /* Like rofidmenu */ + border: 0; + handle-color: @normal-foreground; + handle-width: 8px; + padding: 0; +} + +/* Input bar */ +inputbar { + spacing: 0; + text-color: @normal-foreground; + padding: 1px; + children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; +} + +prompt { + spacing: 0; + text-color: @normal-foreground; +} + +textbox-prompt-colon { + expand: false; + str: ""; + margin: 0px 0.3em 0em 0em; + text-color: @normal-foreground; +} + +entry { + spacing: 0; + text-color: @normal-foreground; +} + +case-indicator { + spacing: 0; + text-color: @normal-foreground; +} + +message { + border: 2px 0px 0px; + border-color: @separatorcolor; + padding: 1px; +} + +textbox { + text-color: @foreground; +} + +mode-switcher { + border: 2px 0px 0px; + border-color: @separatorcolor; +} + +button { + spacing: 0; + text-color: @normal-foreground; +} + +button.selected { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} + +/*------------------------------------------------------- + * PREVIOUS CONFIGURATIONS (commented for reference) + *------------------------------------------------------- + * + * Ultra-compact version had: + * - Font: 8pt + * - Window padding: 10px + * - List lines: 12 + * - Element padding: 1px vertical + * - Spacing: 1px + * - Icons: disabled + * + * Comfortable version had: + * - Element padding: 3px all sides + * - Spacing: 4px + * + * Current version (compact vertical): + * - Font: 10pt + * - Window padding: 30px (like rofidmenu) + * - List lines: 10 + * - Element padding: 1px vertical, 3px horizontal + * - Spacing: 2px (smaller vertical gaps) + * - Icons: enabled for images + */ -- cgit v1.2.3