[SOLVED] How to Change Bar Colors

Forum rules
We don't support installations in VirtualBox, VMWare, qemu or others. We ignore posts about WINE, PlayOnLinux, Steam and Skype. We don't support btrfs, lvm, UEFI, side-by-side installations with GPT or dualboot with anything newer than Windows XP.
Google your problem first. Check the Wiki. Read the existing threads. It's okay to "hijack" an existing thread, yes! If your problem is not yet covered, open a new thread. To get the quickest possible help, mention the exact release codename in your post (uname -a is a good idea, too). Due to the lack of crystal balls, attach the output of lspci -nnk if you encounter hardware problems.
User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

[SOLVED] How to Change Bar Colors

Unread post by Dr_Chroot » Thu Jan 29, 2015 3:51 pm

Out of curiosity, how do you get bar to match the .Xresources colors? I thought that perhaps the palette.pl in the bar repo would do what I am looking for, but it only returns an error.

Edit: So I just thought of something, and ran

Code: Select all

./palette.pl ~/.muhxcolours
and it printed out

Code: Select all

#define BACKGROUND 0x25262b
#define FOREGROUND 0x1a9eba
#define COLOR0 0x024f50
#define COLOR1 0x03b9c7
#define COLOR2 0x039ea3
#define COLOR3 0x046a6b
#define COLOR4 0x05312e
#define COLOR5 0x0fdbe6
#define COLOR6 0x120e06
#define COLOR7 0x14251b
#define COLOR8 0x281905
#define COLOR9 0x332309
Now to find where to put them... bar.c?
Last edited by Dr_Chroot on Tue Feb 10, 2015 9:50 pm, edited 1 time in total.
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 3:57 pm

Just guessing, it should be in bar.c, where you see "here be dragons".
..gnutella..

User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

Re: How to Change Bar Colors

Unread post by Dr_Chroot » Thu Jan 29, 2015 4:11 pm

Hmm... good guess, but that doesn't seem to work, either.

Code: Select all

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <signal.h>
#include <poll.h>
#include <getopt.h>
#include <unistd.h>
#include <errno.h>
#include <xcb/xcb.h>
#include <xcb/xinerama.h>
#include <xcb/randr.h>

// Here be dragons                                                                               

#define BACKGROUND 0x25262b
#define FOREGROUND 0x1a9eba
#define COLOR0 0x024f50
#define COLOR1 0x03b9c7
#define COLOR2 0x039ea3
#define COLOR3 0x046a6b
#define COLOR4 0x05312e
#define COLOR5 0x0fdbe6
#define COLOR6 0x120e06
#define COLOR7 0x14251b
#define COLOR8 0x281905
#define COLOR9 0x332309

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define indexof(c,s) (strchr((s),(c))-(s))
Then I did "make" and "sudo make install". Amirite?
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 4:12 pm

Wait a moment, I try :)
..gnutella..

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 4:17 pm

Yes sir, as you said. make, sudo make install. Does it throw out errors?
..gnutella..

User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

Re: How to Change Bar Colors

Unread post by Dr_Chroot » Thu Jan 29, 2015 4:18 pm

^ Nein,

Code: Select all

 ~/git/bar »  make
cc -std=c99 -Os -o bar.o -c bar.c
cc -o bar bar.o -lxcb -lxcb-xinerama -lxcb-randr

 ~/git/bar »  sudo make install
[sudo] password for neihai: 
pod2man --section=1 --center="bar Manual" --name "bar" --release="bar 6959085" README.pod > bar.1
install -D -m 755 bar /usr/bin/bar
install -D -m 644 bar.1 /usr/share/man/man1/bar.1

 ~/git/bar »  
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 4:25 pm

So what exactly "doesn't seem to work"?
..gnutella..

User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

Re: How to Change Bar Colors

Unread post by Dr_Chroot » Thu Jan 29, 2015 4:26 pm

@MB I couldn't get my xcolors to work with it... but I may have it fixed now. Sorry :D

One moment... just thought of something. Do I need to change my .statsbar?

Code: Select all

#!/bin/sh                                                                                                                           
# z3bra + dkeg. I took it, removed some lines and then mutilated it.                                                                
# Then repaired it with dkeg and z3bras configs again. So it is still mostly theirs.                                                

temp() {
    awk '{print $1/1000}' /sys/class/thermal/thermal_zone0/temp
}
mem() {
    free -m | awk 'NR==3 {print $3}'
}
clock() {
    date +'%e %b %R'
}
batt() {
    cat /sys/class/power_supply/BAT0/capacity 2>/dev/null
}
music() {
    cmusbar 2>/dev/null
}
vol() {
    amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/' | sed -e 's/%//g'
}
tags() {
    herbstclient list_monitors | awk '{gsub(/"/," ");print $5}'
    #herbstclient tag_status                                                                                                        
}
pingd() {
    $HOME/bin/pingd
}

# Fill buffer, output it to stdout.                                                                                                 
while :; do
    buf="%{l} %{B#FFeeeeee} "
    buf="${buf} %{F#FFa69c8e} batt "
    buf="${buf} %{F#FF1d1f21} $(batt) "
    buf="${buf} %{F#FFa69c8e} mem "
    buf="${buf} %{F#FF1d1f21} $(mem) "
    buf="${buf} %{F#FFa69c8e} vol "
    buf="${buf} %{F#FF1d1f21} $(vol) %{c}"
#    buf="${buf} %{F#FF120f20} $(music) %{r}"                                                                                       
#    buf="${buf} %{F#FFa69c8e} $(pingd) "                                                                                           
    buf="${buf} %{F#FFFFFFFF} $() "
    buf="${buf} %{F#FFFFFFFF} $() "
    buf="${buf} %{F#FFFFFFFF} $() "
    buf="${buf} %{F#FFFFFFFF} $() "
    buf="${buf} %{F#FF1d1f21} $(clock) "
    buf="${buf} %{F#FFFFFFFF} $() "
    buf="${buf} %{F#FFFFFFFF} $() "
    buf="${buf} %{F#FFFFFFFF} $() "

    echo $buf
    sleep 1
done
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

Re: How to Change Bar Colors

Unread post by Dr_Chroot » Thu Jan 29, 2015 4:29 pm

Ha! Here I have it! I am an idiot. Sorry, MB :/ Just needed to change my statsbar config. If I had dogecoin, I would you buy you a drink...
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 4:30 pm

Well there are hard-coded colors in the fill-buffer section, if my swollen eyes see it right.

F#FFFFFFFFFF is definitely white. You probably want to use your .Xresources colors there, instead of hardcoded ones.
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How to Change Bar Colors

Unread post by dkeg » Thu Jan 29, 2015 4:31 pm

We have a winner ....

Work hard; Complain less

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How to Change Bar Colors

Unread post by dkeg » Thu Jan 29, 2015 4:32 pm

There is a lesson here.

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 4:35 pm

You can write a little script that changes those colors matching to those that "xrdb -query all" spits out. You would use something like

Code: Select all

# Fill buffer, output it to stdout.                                                                                                 
while :; do
    buf="%{l} %{B#FF$color0} "
    buf="${buf} %{F#FF$color6} batt "
    buf="${buf} %{F#FF$color3} $(batt) "
    buf="${buf} %{F#FF$color3} mem "
    buf="${buf} %{F#FF$color3} $(mem) "
    buf="${buf} %{F#FF$color3} vol "
    buf="${buf} %{F#FF$color4} $(vol) %{c}"
#    buf="${buf} %{F#FF$color4} $(music) %{r}"                                                                                       
#    buf="${buf} %{F#FF$color6} $(pingd) "                                                                                           
    buf="${buf} %{F#FF$color0} $() "
    buf="${buf} %{F#FF$color0} $() "
    buf="${buf} %{F#FF$color0} $() "
    buf="${buf} %{F#FF$color0} $() "
    buf="${buf} %{F#FF$color6} $(clock) "
    buf="${buf} %{F#FF$color0} $() "
    buf="${buf} %{F#FF$color0} $() "
    buf="${buf} %{F#FF$color0} $() "

    echo $buf
    sleep 1
done
in your stats script, and then do some sed action and simply add the color strings from 'xrdb -q all' in the top part of the stats script, as variables.

Code: Select all

xrdb -query all | grep color |awk -F'#' '{print $1 $2}' >~/.statscolors.cfg 
and so on, no idea now :D
..gnutella..

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 4:48 pm

sorry, edit: the method before is bullshit, but you probably know what I mean :D
..gnutella..

User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

Re: How to Change Bar Colors

Unread post by Dr_Chroot » Thu Jan 29, 2015 4:49 pm

Fantastic! Thanks so much for your help... you have made my day :D (And my future ricing much faster!)

@dkeg Jeez, no kidding. This is embarrassing, but at least I will never forget to check all possible configs first :)
Attachments
thanks.png
Last edited by Dr_Chroot on Thu Jan 29, 2015 4:51 pm, edited 1 time in total.
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: How to Change Bar Colors

Unread post by machinebacon » Thu Jan 29, 2015 4:51 pm

^ yes, that's how they ...

...wow, nice colors!!
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How to Change Bar Colors

Unread post by dkeg » Thu Jan 29, 2015 5:05 pm

Yes. You can easily set variables.
I mapped something like that out in my head to help automate some of the manual processes I do for scheme creation.

Work hard; Complain less

User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

Re: How to Change Bar Colors

Unread post by Dr_Chroot » Thu Jan 29, 2015 5:05 pm

machinebacon wrote:^ yes, that's how they ...

...wow, nice colors!!
Thanks! I should probably add more oranges into my xcolors to match the bar, but I also like the greens in there too.

I was originally trying to emulate this watch with this strap and it all went downhill from there... I had a hard time tossing orange into the xcolors, but I might tweak with them a bit more and do just that. it worked splendidly with the bar, though :D
Last edited by Dr_Chroot on Thu Jan 29, 2015 5:09 pm, edited 1 time in total.
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How to Change Bar Colors

Unread post by dkeg » Thu Jan 29, 2015 5:06 pm

All the fun happens while I'm at work

Work hard; Complain less

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How to Change Bar Colors

Unread post by dkeg » Fri Jan 30, 2015 3:16 am

I'm off my phone now, and can probably add some stuff here. In previouses releases of BAR, yes, you would have made changes as you describe above. Not sure when, but maybe even close to a year ago, BAR was re-written to be more dynamic and w/o a config.h, removing the need to compile. One would follow the syntax for colors, font, position, etc.
https://github.com/LemonBoy/bar
so for instance

Code: Select all

#! /bin/bash

# cool status script

#colors
bg='%{B#FF111111}'
fg='${F#FF999999}'
white='%{F#FFFFFFFF}'
black='%{F#FF000000}'

output1 (){
stuff
}
output2 (){
stuff
}
output3 (){
stuff
}
sleep 2
echo $bg $white${output1}%{c} $white{output2}%{r} $white${output3}
elsewhere

Code: Select all

coolstats|bar widthxhieght+x+y -p -f <font> &
Disclaimer: something like that

Work hard; Complain less

Post Reply