Palleter
Forum rules
Your own work only.
Your own work only.
Re: Palleter
^ very nice!
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
Re: Palleter
Bug squashing - make the script fool-proof.
New version based on the original sript:
New version based on the original sript:
Code: Select all
#!/bin/bash
# takes an image and creates a color palette from it
# which gets echoed to the console.
#
# made by rhowaldt (fuck you)
#
# depends: imagemagick
# Squashed Bugs
# Bug #1:
# when the script is launched without arguments, it hangs in convert
# because convert is then expecting its input from stdin.
# This is not bad in itself, but it can be confusing because the user
# is not aware of it.
# Solution for Bug #1:
# Test for $1 not equal to the empty string to read from an image file.
# If there is no argument to the program, warn the user about the program
# reading its input from stdin.
# Bug #2:
# The convert command produces an empty line as the last line in its output.
# There is no need to transform that empty line to an escape sequence,
# though there don't seem to be any averse effects.
# Solution for Bug #2:
# Test for for an empty line within the read command and break when you encounter it.
[[ "$1" ]] || {
printf '%s\n' "You have not supplied the path to an image to be sampled.
${0} will read the image from stdin.
If that is what you intended, you can ignore this message.
If that is _NOT_ what you intended, press Ctrl-D on an empty line to stop reading stdin.
There will be an error message from the 'convert' utility that you can ignore.
Restart the program with the path to the image as argument."
} >&2
COL=("0" "8" "1" "9" "2" "A" "3" "B" "4" "C" "5" "D" "6" "E" "7" "F");
x=0
while read -r line; do
[[ "$line" ]] || continue
echo -en "\e]P${COL[$x]}$line";
x=$((x+1))
done < <(convert "$1" -colors 16 -format "%c" histogram:info: | sed 's/^.*\#\(.*\) srgb.*/\1/g')
Connected. Take this REPL, brother, and may it serve you well.
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Palleter
thanks for the squash and the link before, of course it makes more sense in the evening than in the morning :D
..gnutella..
Re: Palleter
Doesi t not depend on how late in the evening it is?
Connected. Take this REPL, brother, and may it serve you well.
Re: Palleter
ah xaos, good points. i usually fix for at least the $1-check but i was so excited at having made another script after some time that i slapped it online immediately :) - thanks, very nice.
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
Re: Palleter
No problem, Rhowald.
I am glad you can handle criticism positively.
What you are saying is true for almost all new scripts.
All need some usage, throwing out all sorts of arguments at them, to weed out the weaknesses and make em better.
I am glad you can handle criticism positively.
What you are saying is true for almost all new scripts.
All need some usage, throwing out all sorts of arguments at them, to weed out the weaknesses and make em better.
Connected. Take this REPL, brother, and may it serve you well.
Re: Palleter
much agreed xaos. and i really appreciate people (such as yourself) taking the time to look at these scripts and improving on them. in the end, all we really want is to make nice shit, right? so let's do it together while we're at this BBQ, combined efforts and all :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
- mrneilypops
- Bad Advice Dog
- Posts: 143
- Joined: Wed Oct 17, 2012 9:15 pm
- Location: Luxembourg
- Contact:
Re: Palleter
@xaos52
I am using your version of palleter but this is the output it gives me in terminator and urxvt;
Probably me having a really blonde day but how can I get a more sensible output?
The colours work but it is a bit of a pain copy/pasting into ~/.Xresources.
I am using your version of palleter but this is the output it gives me in terminator and urxvt;
Code: Select all
live@wheezy:~$ ./palleter1.sh /home/live/images/lightrails.png
]P0080604]P8241F20]P1261A12]P92D231C]P2352B25]PA48392E]P3532510]PB5C4738]P46E5849]PC90705A]P59B532A]PDAC8C72]P6CEB197]PED39E6F]P7D9BFA7]PFF9F2E9live@wheezy:~$
The colours work but it is a bit of a pain copy/pasting into ~/.Xresources.
Re: Palleter
The script is not ready yet.
For the moment it works only for the console and for xterm.
I am working on relieving you from that pain, but you will have to be a little patient.
I expect the script to be fully functional in the course of next week.
For the moment it works only for the console and for xterm.
I am working on relieving you from that pain, but you will have to be a little patient.
I expect the script to be fully functional in the course of next week.
Connected. Take this REPL, brother, and may it serve you well.
- mrneilypops
- Bad Advice Dog
- Posts: 143
- Joined: Wed Oct 17, 2012 9:15 pm
- Location: Luxembourg
- Contact:
Re: Palleter
@xaos52
Perfect...just testing at the moment and I don't want to appear too lazy with copy/paste.
The colours come out great (for me) on my test;
http://fav.me/d6tgysu
...but it would be great to just have the column of colours to copy into ~/.Xresources...maybe...
keep up the FAB work...this is goin down a storm on the grapevine!
Perfect...just testing at the moment and I don't want to appear too lazy with copy/paste.
The colours come out great (for me) on my test;
http://fav.me/d6tgysu
...but it would be great to just have the column of colours to copy into ~/.Xresources...maybe...
keep up the FAB work...this is goin down a storm on the grapevine!
Re: Palleter
I posted a solution that works for me a bit further up in the thread. I have made adjustments based on updates from others (the doctor). I named my paletterX for differentation.
I use this way
then I can simply c/p the output accordingly.
also you could have a look at this and this script might prove useful too.
edit - I see xaos already responded, but I already typed all this up, so I'm leaving it :D
Code: Select all
#!/bin/bash
# takes an image and creates a color palette from it
# depends: imagemagick
PALETTE=$(convert "$1" -colors 16 -format "%c" histogram:info:)
HEXLIST=$(echo "$PALETTE" | sed 's/^.*\#\(.*\) srgb.*/\1/g')
COL=("0" "8" "1" "9" "2" "A" "3" "B" "4" "C" "5" "D" "6" "E" "7" "F");
CLEAN=$(echo $COL | sed 's/^0*//')
x=0
## Get the ouput of the color palette
while read -r line; do
[[ "$line" ]] || continue
echo -en *color$x: '#'"${CLEAN}$line\n";
x=$((x+1))
done < <(convert "$1" -colors 16 -format "%c" histogram:info: | sed 's/^.*\#\(.*\) srgb.*/\1/g')
Code: Select all
./paletterX ~/path/to/wall.jpg > temp && [editor] temp &
also you could have a look at this and this script might prove useful too.
edit - I see xaos already responded, but I already typed all this up, so I'm leaving it :D
Work hard; Complain less
Re: Palleter
haha OK :)
Just hold your horses for a while yet.
It is going to happen.
Just hold your horses for a while yet.
It is going to happen.
Connected. Take this REPL, brother, and may it serve you well.
Re: Palleter
I'll tell ya, this whole thing has really turned into quite an awesome and awe inspiring project. seriously, this final result is going to be great. We Rock!!
Work hard; Complain less
Re: Palleter
thanks again for all the work expanding on this script xaos and dkeg. indeed, it's gonna be beautiful, and we'll never be at a loss for colorthemes anymore :D
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
- mrneilypops
- Bad Advice Dog
- Posts: 143
- Joined: Wed Oct 17, 2012 9:15 pm
- Location: Luxembourg
- Contact:
Re: Palleter
Thanks All - I really appreciate this work!
Re: Palleter
@rhowald - this would not have happened without your brilliant convert/histogram idea.
Connected. Take this REPL, brother, and may it serve you well.
Re: Palleter
@xaos: thanks mate. keep up the good shit :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
Re: Palleter
Has anyone tried the version of palleter as posted earlier by 'fog' on terminator?
I could have sworn that it worked for me earlier, but it does no more.
Not on a jessie based system, nor on a sid based one.
I have no clue why the behaviour changed.
Can someone else, who is used to using terminator, test that script again and let me know if it works for him/her.
I am struggling to find a method to change terminal colors in terminator dynamically.
Thanks to the able and the willing,
xaos
PS: I am now thinking I was wrong, and it did not work to dynamically change the colors.
I guess fog just used the output from the script and copied it into the terminator config file.
It never worked 'on the fly'.
I could update the config file automatically with the new palette, saving some 'manual editing'.
Suspending for now.
I could have sworn that it worked for me earlier, but it does no more.
Not on a jessie based system, nor on a sid based one.
I have no clue why the behaviour changed.
Can someone else, who is used to using terminator, test that script again and let me know if it works for him/her.
I am struggling to find a method to change terminal colors in terminator dynamically.
Thanks to the able and the willing,
xaos
PS: I am now thinking I was wrong, and it did not work to dynamically change the colors.
I guess fog just used the output from the script and copied it into the terminator config file.
It never worked 'on the fly'.
I could update the config file automatically with the new palette, saving some 'manual editing'.
Suspending for now.
Connected. Take this REPL, brother, and may it serve you well.
Re: Palleter
I'm just trying to make sure I understand how the paletter/paletterx script works. When you invoke the script, what is happening? Where does the info that it pulls from the current wallpaper go? When I invoke the script, I seem to only get a blinking cursor, and it never returns to a new bash prompt. What further steps do I need to take?