mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 10:30:44 +02:00
Auto: cleanup-2026-05-24T10-18-36Z
This commit is contained in:
@@ -1,75 +1,74 @@
|
||||
{ ... }: {
|
||||
|
||||
perSystem = { pkgs, ... }: {
|
||||
packages.custom-colorpicker = pkgs.writeShellApplication {
|
||||
# useless. Just use hyprpicker
|
||||
name = "custom-colorpicker";
|
||||
runtimeInputs = with pkgs; [
|
||||
hyprpicker
|
||||
libnotify
|
||||
toybox
|
||||
wl-clipboard
|
||||
];
|
||||
text = ''
|
||||
check() {
|
||||
command -v "$1" 1>/dev/null
|
||||
}
|
||||
|
||||
notify() {
|
||||
check notify-send && {
|
||||
notify-send -a "Color Picker" "$@"
|
||||
return
|
||||
_: {
|
||||
perSystem = {pkgs, ...}: {
|
||||
packages.custom-colorpicker = pkgs.writeShellApplication {
|
||||
# useless. Just use hyprpicker
|
||||
name = "custom-colorpicker";
|
||||
runtimeInputs = with pkgs; [
|
||||
hyprpicker
|
||||
libnotify
|
||||
toybox
|
||||
wl-clipboard
|
||||
];
|
||||
text = ''
|
||||
check() {
|
||||
command -v "$1" 1>/dev/null
|
||||
}
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
loc="$HOME/.cache/colorpicker"
|
||||
[ -d "$loc" ] || mkdir -p "$loc"
|
||||
[ -f "$loc/colors" ] || touch "$loc/colors"
|
||||
|
||||
limit=10
|
||||
|
||||
[[ $# -eq 1 && $1 = "-l" ]] && {
|
||||
cat "$loc/colors"
|
||||
exit
|
||||
}
|
||||
|
||||
[[ $# -eq 1 && $1 = "-j" ]] && {
|
||||
text="$(head -n 1 "$loc/colors")"
|
||||
|
||||
mapfile -t allcolors < <(tail -n +2 "$loc/colors")
|
||||
# allcolors=($(tail -n +2 "$loc/colors"))
|
||||
tooltip="<b> COLORS</b>\n\n"
|
||||
|
||||
tooltip+="-> <b>$text</b> <span color='$text'></span> \n"
|
||||
for i in "''${allcolors[@]}"; do
|
||||
tooltip+=" <b>$i</b> <span color='$i'></span> \n"
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
{ "text":"<span color='$text'></span>", "tooltip":"$tooltip"}
|
||||
EOF
|
||||
|
||||
exit
|
||||
}
|
||||
|
||||
check hyprpicker || {
|
||||
notify "hyprpicker is not installed"
|
||||
exit
|
||||
}
|
||||
killall -q hyprpicker
|
||||
color=$(hyprpicker)
|
||||
|
||||
check wl-copy && {
|
||||
echo "$color" | sed -z 's/\n//g' | wl-copy
|
||||
}
|
||||
|
||||
prevColors=$(head -n $((limit - 1)) "$loc/colors")
|
||||
echo "$color" >"$loc/colors"
|
||||
echo "$prevColors" >>"$loc/colors"
|
||||
sed -i '/^$/d' "$loc/colors"
|
||||
pkill -RTMIN+1 waybar
|
||||
'';
|
||||
|
||||
notify() {
|
||||
check notify-send && {
|
||||
notify-send -a "Color Picker" "$@"
|
||||
return
|
||||
}
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
loc="$HOME/.cache/colorpicker"
|
||||
[ -d "$loc" ] || mkdir -p "$loc"
|
||||
[ -f "$loc/colors" ] || touch "$loc/colors"
|
||||
|
||||
limit=10
|
||||
|
||||
[[ $# -eq 1 && $1 = "-l" ]] && {
|
||||
cat "$loc/colors"
|
||||
exit
|
||||
}
|
||||
|
||||
[[ $# -eq 1 && $1 = "-j" ]] && {
|
||||
text="$(head -n 1 "$loc/colors")"
|
||||
|
||||
mapfile -t allcolors < <(tail -n +2 "$loc/colors")
|
||||
# allcolors=($(tail -n +2 "$loc/colors"))
|
||||
tooltip="<b> COLORS</b>\n\n"
|
||||
|
||||
tooltip+="-> <b>$text</b> <span color='$text'></span> \n"
|
||||
for i in "''${allcolors[@]}"; do
|
||||
tooltip+=" <b>$i</b> <span color='$i'></span> \n"
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
{ "text":"<span color='$text'></span>", "tooltip":"$tooltip"}
|
||||
EOF
|
||||
|
||||
exit
|
||||
}
|
||||
|
||||
check hyprpicker || {
|
||||
notify "hyprpicker is not installed"
|
||||
exit
|
||||
}
|
||||
killall -q hyprpicker
|
||||
color=$(hyprpicker)
|
||||
|
||||
check wl-copy && {
|
||||
echo "$color" | sed -z 's/\n//g' | wl-copy
|
||||
}
|
||||
|
||||
prevColors=$(head -n $((limit - 1)) "$loc/colors")
|
||||
echo "$color" >"$loc/colors"
|
||||
echo "$prevColors" >>"$loc/colors"
|
||||
sed -i '/^$/d' "$loc/colors"
|
||||
pkill -RTMIN+1 waybar
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user