From b4a62c0b9d40414f4ab32ff2d6ae55cc34cf5c03 Mon Sep 17 00:00:00 2001 From: bh Date: Sun, 22 Mar 2026 23:04:45 +0800 Subject: Add Scripts folder and clean things up --- .media/hyprland_1.png | Bin 0 -> 1434306 bytes .media/hyprland_2.png | Bin 0 -> 1031896 bytes Media/hyprland_1.png | Bin 1434306 -> 0 bytes Media/hyprland_2.png | Bin 1031896 -> 0 bytes README.md | 4 +- Scripts/Scripts/clipboard | 29 +++ Scripts/Scripts/mute | 14 + Scripts/Scripts/screenshot | 15 ++ Scripts/Scripts/tt | 20 ++ Scripts/Scripts/tt.elf | Bin 0 -> 4136592 bytes hypr/.config/hypr/hyprland.conf | 7 +- hypr/.config/hypr/scripts/mute | 14 - hypr/.config/hypr/scripts/screenshot | 15 -- .../rofi/scripts/clipboard-launcher-enhanced.sh | 281 --------------------- rofi/.config/rofi/scripts/clipboard-launcher.sh | 59 ----- rofi/.config/rofi/scripts/clipboard-wayland.sh | 29 --- zsh/Zsh/tt | 20 -- zsh/Zsh/tt.elf | Bin 4136592 -> 0 bytes 18 files changed, 83 insertions(+), 424 deletions(-) create mode 100644 .media/hyprland_1.png create mode 100644 .media/hyprland_2.png delete mode 100644 Media/hyprland_1.png delete mode 100644 Media/hyprland_2.png create mode 100755 Scripts/Scripts/clipboard create mode 100755 Scripts/Scripts/mute create mode 100755 Scripts/Scripts/screenshot create mode 100755 Scripts/Scripts/tt create mode 100755 Scripts/Scripts/tt.elf delete mode 100755 hypr/.config/hypr/scripts/mute delete mode 100755 hypr/.config/hypr/scripts/screenshot delete mode 100755 rofi/.config/rofi/scripts/clipboard-launcher-enhanced.sh delete mode 100755 rofi/.config/rofi/scripts/clipboard-launcher.sh delete mode 100755 rofi/.config/rofi/scripts/clipboard-wayland.sh delete mode 100755 zsh/Zsh/tt delete mode 100755 zsh/Zsh/tt.elf diff --git a/.media/hyprland_1.png b/.media/hyprland_1.png new file mode 100644 index 0000000..4149656 Binary files /dev/null and b/.media/hyprland_1.png differ diff --git a/.media/hyprland_2.png b/.media/hyprland_2.png new file mode 100644 index 0000000..e6064c3 Binary files /dev/null and b/.media/hyprland_2.png differ diff --git a/Media/hyprland_1.png b/Media/hyprland_1.png deleted file mode 100644 index 4149656..0000000 Binary files a/Media/hyprland_1.png and /dev/null differ diff --git a/Media/hyprland_2.png b/Media/hyprland_2.png deleted file mode 100644 index e6064c3..0000000 Binary files a/Media/hyprland_2.png and /dev/null differ diff --git a/README.md b/README.md index 9dec4d4..5570e45 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,6 @@ Personal dotfiles. ## Screenshots -![](Media/hyprland_1.png) +![](.media/hyprland_1.png) -![](Media/hyprland_2.png) +![](.media/hyprland_2.png) diff --git a/Scripts/Scripts/clipboard b/Scripts/Scripts/clipboard new file mode 100755 index 0000000..93789a0 --- /dev/null +++ b/Scripts/Scripts/clipboard @@ -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/Scripts/Scripts/mute b/Scripts/Scripts/mute new file mode 100755 index 0000000..ad61d7d --- /dev/null +++ b/Scripts/Scripts/mute @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Toggle mute +pactl set-sink-mute @DEFAULT_SINK@ toggle + +# Get mute status +MUTE=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}') + +if [ "$MUTE" = "yes" ]; then + dunstify "󰖁 Volume: Muted" -r 2593 -t 1000 +else + VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po "\d+%" | head -1) + dunstify " Volume: $VOLUME" -h int:value:${VOLUME%\%} -r 2593 -t 1000 +fi diff --git a/Scripts/Scripts/screenshot b/Scripts/Scripts/screenshot new file mode 100755 index 0000000..5ed5b7d --- /dev/null +++ b/Scripts/Scripts/screenshot @@ -0,0 +1,15 @@ +#!/bin/bash + +mkdir -p ~/Pictures/Screenshots + +FILE=~/Pictures/Screenshots/$(date '+%Y-%m-%d_%H-%M-%S').png + +if [[ "$1" == "snip" ]]; then + grim -g "$(slurp)" "$FILE" || exit 1 +else + grim "$FILE" || exit 1 +fi + +wl-copy --type image/png < "$FILE" + +notify-send "Screenshot Taken" "Saved to $FILE" -i "$FILE" diff --git a/Scripts/Scripts/tt b/Scripts/Scripts/tt new file mode 100755 index 0000000..48824a3 --- /dev/null +++ b/Scripts/Scripts/tt @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# How much to zoom in +ZOOM="+12" + +# Store current font size +# ORIG_SIZE=$(kitty @ get-font-size) + +# Zoom in +kitty @ set-font-size "$ZOOM" + +# Restore on exit +restore_font() { + # kitty @ set-font-size "$ORIG_SIZE" + kitty @ set-font-size 10.5 +} +trap restore_font EXIT + +# Run tt +~/Zsh/tt.elf -notheme diff --git a/Scripts/Scripts/tt.elf b/Scripts/Scripts/tt.elf new file mode 100755 index 0000000..8c85e9a Binary files /dev/null and b/Scripts/Scripts/tt.elf differ diff --git a/hypr/.config/hypr/hyprland.conf b/hypr/.config/hypr/hyprland.conf index 048a9fa..5dde431 100644 --- a/hypr/.config/hypr/hyprland.conf +++ b/hypr/.config/hypr/hyprland.conf @@ -192,10 +192,9 @@ bind = $mainMod, D, exec, $menu bind = $mainMod, E, exec, emacs # 📜 Scripts -bind = $mainMod, V, exec, ~/.config/rofi/scripts/clipboard-wayland.sh -bind = $mainMod, S, exec, ~/.config/hypr/scripts/screenshot -bind = $mainMod SHIFT, S, exec, ~/.config/hypr/scripts/screenshot snip -bind = $mainMod, slash, exec, ~/Scripts/blur-lock +bind = $mainMod, V, exec, ~/Scripts/clipboard +bind = $mainMod, S, exec, ~/Scripts/screenshot +bind = $mainMod SHIFT, S, exec, ~/Scripts/screenshot snip # 🪟 Window Management bind = $mainMod SHIFT, C, killactive, diff --git a/hypr/.config/hypr/scripts/mute b/hypr/.config/hypr/scripts/mute deleted file mode 100755 index ad61d7d..0000000 --- a/hypr/.config/hypr/scripts/mute +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# Toggle mute -pactl set-sink-mute @DEFAULT_SINK@ toggle - -# Get mute status -MUTE=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}') - -if [ "$MUTE" = "yes" ]; then - dunstify "󰖁 Volume: Muted" -r 2593 -t 1000 -else - VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -Po "\d+%" | head -1) - dunstify " Volume: $VOLUME" -h int:value:${VOLUME%\%} -r 2593 -t 1000 -fi diff --git a/hypr/.config/hypr/scripts/screenshot b/hypr/.config/hypr/scripts/screenshot deleted file mode 100755 index 5ed5b7d..0000000 --- a/hypr/.config/hypr/scripts/screenshot +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -mkdir -p ~/Pictures/Screenshots - -FILE=~/Pictures/Screenshots/$(date '+%Y-%m-%d_%H-%M-%S').png - -if [[ "$1" == "snip" ]]; then - grim -g "$(slurp)" "$FILE" || exit 1 -else - grim "$FILE" || exit 1 -fi - -wl-copy --type image/png < "$FILE" - -notify-send "Screenshot Taken" "Saved to $FILE" -i "$FILE" diff --git a/rofi/.config/rofi/scripts/clipboard-launcher-enhanced.sh b/rofi/.config/rofi/scripts/clipboard-launcher-enhanced.sh deleted file mode 100755 index bdee2ec..0000000 --- a/rofi/.config/rofi/scripts/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/scripts/clipboard-launcher.sh b/rofi/.config/rofi/scripts/clipboard-launcher.sh deleted file mode 100755 index c223fe9..0000000 --- a/rofi/.config/rofi/scripts/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/scripts/clipboard-wayland.sh b/rofi/.config/rofi/scripts/clipboard-wayland.sh deleted file mode 100755 index 93789a0..0000000 --- a/rofi/.config/rofi/scripts/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/zsh/Zsh/tt b/zsh/Zsh/tt deleted file mode 100755 index 48824a3..0000000 --- a/zsh/Zsh/tt +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -# How much to zoom in -ZOOM="+12" - -# Store current font size -# ORIG_SIZE=$(kitty @ get-font-size) - -# Zoom in -kitty @ set-font-size "$ZOOM" - -# Restore on exit -restore_font() { - # kitty @ set-font-size "$ORIG_SIZE" - kitty @ set-font-size 10.5 -} -trap restore_font EXIT - -# Run tt -~/Zsh/tt.elf -notheme diff --git a/zsh/Zsh/tt.elf b/zsh/Zsh/tt.elf deleted file mode 100755 index 8c85e9a..0000000 Binary files a/zsh/Zsh/tt.elf and /dev/null differ -- cgit v1.2.3