Unix3r

Build. Break. Learn. Repeat.

Starting0%
Skip to content

unix3r/dotfiles

Public
main
U Unix3r Initial commit: sway + waybar dotfiles (Catppuccin Mocha) eb290df
16 lines · 673 B Raw History
1#!/usr/bin/env bash
2# colorpicker.sh — click a pixel, get its hex colour in the clipboard.
3source "$(dirname "$0")/_lib.sh"
4point=$(slurp -p -b '#00000000') || exit 0
5
6if has magick; then conv=(magick); elif has convert; then conv=(convert)
7else notify color dialog-error "Colour picker" "Install imagemagick"; exit 1; fi
8
9hex=$(grim -g "$point" -t ppm - | "${conv[@]}" - -format '%[hex:p{0,0}]' info:- | cut -c1-6)
10[[ -n $hex ]] || exit 1
11printf '#%s' "$hex" | wl-copy
12
13# Small swatch as the notification icon
14swatch="${XDG_RUNTIME_DIR:-/tmp}/color-$hex.png"
15"${conv[@]}" -size 64x64 "xc:#$hex" "$swatch" 2>/dev/null
16notify color "$swatch" "#$hex" "Copied to clipboard"