Usually to define a color in gtkdialog one would use something like that:
Code: Select all
#DB09AC
Roxfiler is using a 12 digit number like:
Code: Select all
#440044004400
Want to do this from within a bash script!
Thanks.
Code: Select all
#DB09AC
Code: Select all
#440044004400
Whether you care or not is not the issue, I was simply trying to inform you of the possible pitfalls when converting from one colour space to another or you may well be disappointed with the final results.LazY Puppy wrote:Hi.
Thanks for the reply.
Wasn't that helpful to my issue/purpose.
Though, I don't care about 24 bit colors and/or 48 bit colors.
I think you are missing the point.I just want to convert the values like #DB09AC to #14354860....
Code: Select all
#!/bin/sh
printf "0x%X\n" `echo $[(($1 & 0xFF)<<8) + ((($1 >> 8) & 0xFF)<<24) + (($1 >> 16)<<36)]`
# ./script 0x332211
0x330022001100
# ./script 0x8000FF
0x80000000FF00
Code: Select all
# color_12='#440044004400'
# cut -c 1-3,6,7,10,11 <<< "$color_12"
#444444
No, it doesn't.Sailor Enceladus wrote:Is this how it works? I have no idea
Code: Select all
#!/bin/sh printf "0x%x\n" `echo $[(($1 % 0x100)<<8) + ((($1 >> 8) % 0x100)<<24) + (($1 >> 16)<<36)]`
# ./script 0x332211
0x330022001100
# ./script 0x8000ff
0x80000000ff00
I don't care about the correct colours. If there will be something really weird I can change its value manually afterwards....does not mean you are going to get the correct colours
If all you want is the conversion with no regard for colour, then seasides method ain't bad as it's discarding only the lower order.LazY Puppy wrote: I don't care about the correct colours. If there will be something really weird I can change its value manually afterwards.
It's more a general purpose - not focused too much to every single color possible.
Just want to convert those values like it is done in a calculator.
It handles alphabetic characters (look at the example), I was asking if that was how the conversion actually works. Based on Pete's post, I'm guessing it isn't though. Sure, pad some 0s to the front if you want when needed.LazY Puppy wrote:It can't handle alphabetical characters and also it can't handle numbers starting with a 0 (zero) in front.
So, all you want is just hex<->dec conversion?LazY Puppy wrote:Wouldn't it be possible to get the sourcecode of ycalc, just to grab those two functions that are converting hex to dec and dec to hex used to build/compile a binary just performing those two functions?
Code: Select all
# printf '%d\n' 0xdb09ac
14354860
#
# printf '%x\n' 14354860
db09ac
#
Your script works for 24 bit ==> 48 bit as the lower order bytes will always be zeroes.(nice simple script BTW).Sailor Enceladus wrote:Based on Pete's post, I'm guessing it isn't though. Sure, pad some 0s to the front if you want when needed.
Ok, I see.However it has nothing to do with the way ROX stores some colors, e.g. #440044004400 from your first post is not decimal, but 48bit hexadecimal number and its 24bit approximation is #444444.
Where do you find this number? Which file does rox-filer store this in please?LazY Puppy wrote:Roxfiler is using a 12 digit number like:Code: Select all
#440044004400
/root/.config/rox.sourceforge.net/ROX-Filer/Options is one of themgreengeek wrote:Where do you find this number? Which file does rox-filer store this in please?LazY Puppy wrote:Roxfiler is using a 12 digit number like:Code: Select all
#440044004400
Yes, of course. Like the title said.Pete wrote:are you sure that you don't mean 12 digits? which would be 48 bits.
File /root/.config/rox.sourceforge.net/ROX-Filer/Options is the one where the colours to display files are stored at.greengeek wrote:Where do you find this number? Which file does rox-filer store this in please?