Bar-text-bar (en)

From Conky PitStop

(Difference between revisions)
Jump to: navigation, search
(Created page with "__NOTITLE__ =bar-text-bar= __NOTOC__ Category:English Category:Fonts and text (en) Category:Tips and tricks (en) {{i18n|en|bar-text-bar}} <center>'''WARNING:''' ''I...")
 
(5 intermediate revisions not shown)
Line 7: Line 7:
{{i18n|en|bar-text-bar}}
{{i18n|en|bar-text-bar}}
-
<center>'''WARNING:'''  ''If you are using conky v1.8+ this may not work!''<br>
+
'''A complete rewrite thanks to some new tricks.'''
-
''It works with #! Statler - Conky v1.8.0 Debian: Squeeze''</center>
+
OK so someone asked if it was possible to have:
OK so someone asked if it was possible to have:
-
 
+
-- text here --
-
'''-- text here --'''
+
-
 
+
in conky. Where the '''—''' was a solid line similar to the ${hr} command.
in conky. Where the '''—''' was a solid line similar to the ${hr} command.
-
People started by saying, ''“No, not possible.”'' I thought about it for a bit and said to myself, “Yea I can do that!”. With another trick in conky that I have already showed you in "[[Bars with text (en)|Bars with text]]".
+
People started by saying, ''“No, not possible.”'' I thought about it for a bit and said to myself, “Yea I can do that!”. With another trick in conky that I have already showed you in "[[Bars with text inside (en)|Bars with text inside]]".
-
So I set out and experimented and came up with the solution.
+
So I set out and experimented and came up with the solution. ${cpubar cpuX} where X is a cpu you do not have.  ie: cpu3 for a dual-core
-
===Step 1===
+
${alignc}${cpubar cpu 5 1,30} cpubar cpuX ${cpubar cpu5 1,30}
 +
as seen in the image on the right.
-
[[Image:text-here-1.png|center]]
+
'''''Fast forward to April 2014 in the CrunchBang Forums'''''
-
Default text for this conky is: '''font Zekton:size=15'''. I’m actually using my ''“conkyemail”'' which is ''alignment tm'' so that is where the width comes from.
+
'''Marenbraga''' said: I plan to use a bar only as decoration, but I need it filled because of the background color. Any suggestions?
-
You have a title you want to use: System, Temperatures, Music, Weather, whatever. You used ${alignc} or a ${goto xx} command to get it where you want it. We’ll use '''CONKY''' for this example with the woodbadge font, as seen to the left.
+
Use: ${membar} with a height no greater than 1 and a width of 0, along with a creative use of font size. Good idea but requires a lot of them to make a real '''bar'''
 +
However you can even give it stripes:
 +
[[File:Bar-TXT-Bar.jpg|right|200px|thumb|Bar-TXT-Bar]]
 +
The test code that did all that:
 +
default_bar_size 0 12
 +
TEXT
 +
${time %T}${alignr}${time %x}
 +
${alignc}CPU % Usage:
 +
${alignc}1  |  2  |  3  |  A
 +
${alignc}${if_match ${cpu cpu1}<10}00${cpu cpu1}\
 +
${else}${if_match ${cpu cpu1}<100}0${cpu cpu1}\
 +
${else}${color9}${cpu cpu1}${endif}${endif}\
 +
  | ${if_match ${cpu cpu2}<10}00${cpu cpu2}\
 +
${else}${if_match ${cpu cpu2}<100}0${cpu cpu2}\
 +
${else}${color9}${cpu cpu2}${endif}${endif}\
 +
  | ${if_match ${cpu cpu3}<10}00${cpu cpu3}\
 +
${else}${if_match ${cpu cpu3}<100}0${cpu cpu3}\
 +
${else}${color9}${cpu cpu3}${endif}${endif}\
 +
  | ${if_match ${cpu cpu0}<10}00${cpu cpu0}\
 +
${else}${if_match ${cpu cpu0}<100}0${cpu cpu0}\
 +
${else}${cpu cpu0}${endif}${endif}
 +
 +
${alignc}${cpubar cpu4 0,30} cpubar cpu4 ${cpubar cpu4 0,30}
 +
${alignc}${cpubar cpu4 1,30} cpubar cpu4 ${cpubar cpu4 1,30}
 +
 +
${alignc}${membar 1,30} use membar ${membar 1,30}
 +
${font :size=1}${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}${font}
 +
${font :size=1}${color}${membar 1,0}
 +
${membar 1,0}
 +
${membar 1,0}${color blue}
 +
${membar 1,0}
 +
${membar 1,0}${color}
 +
${membar 1,0}
 +
${membar 1,0}${color blue}
 +
${membar 1,0}
 +
${membar 1,0}${color}
 +
${membar 1,0}
 +
${membar 1,0}${color blue}
 +
${membar 1,0}
 +
${membar 1,0}${color}
 +
${membar 1,0}
 +
${membar 1,0}${font}
 +
${alignc}${membar 0,75} Conky PitStop ${membar 0,75}
 +
${membar 0,0}
 +
${alignc}${membar 1,75} Conky PitStop ${membar 1,75}
 +
${membar 1,0}
 +
${alignc}${membar 2,75} Conky PitStop ${membar 2,75}
 +
${membar 3,0}${goto 6}${color red}${membar 1,0}${color}
 +
${membar 2,0}${goto 6}${color blue}${membar 0,0}${color}
 +
${alignc}${membar 1,30} pvsage's idea ${membar 1,30}
 +
${alignc}${membar 1,30} use  execbar ${membar 1,30}
 +
20  ${execbar echo 20}
 +
40  ${execbar echo 40}${goto 150}${voffset -1}${color5}pvsage's idea${color}${voffset 1}
 +
60  ${execbar echo 60}
 +
80  ${execbar echo 80}
 +
100 ${execbar echo 100}${goto 50}${voffset -1}${color 000000}pvsage's idea${color}${voffset 1}
 +
${execbar echo 100}${goto 50}${voffset -1}${color 000000}pvsage's idea${color}${voffset 1}
 +
 +
 +
 +
 +
${alignc}${membar 1,30} pvsage expanded idea ${membar 1,30}
 +
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu}${color}${goto 40}Avg: ${voffset 1}${cpubar cpu0 12}
 +
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu cpu1}${color}${goto 40}  1: ${voffset 1}${cpubar cpu1 12}
 +
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu cpu2}${color}${goto 40}  2: ${voffset 1}${cpubar cpu2 12}
 +
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu cpu3}${color}${goto 40}  3: ${voffset 1}${cpubar cpu3 12}
 +
 +
${hr 10}${goto 20}${voffset 2}${color 000000}and great one too!${color}${voffset -2}
 +
  ${hr}
  ${hr}
-
  ${goto 95}${font woodbadge:size=20}${color2}Conky${color}${font}
+
  ${font woodbadge:size=20}${alignc}${color  chocolate}Conky${color}${font}
 +
${color yellow}${voffset -15}${membar 3,70}${alignr 2}${membar 3,70}${color}${voffset 15}
 +
${color red}${voffset -29}${membar 1,70}${alignr 2}${membar 1,70}${color}${voffset 15}
 +
${font woodbadge:size=20}${alignc}${color  chocolate}PitStop${color}${font}
 +
${color yellow}${voffset -15}${membar 3,70}${alignr 2}${membar 3,70}${color}${voffset 15}
 +
${color red}${voffset -29}${membar 1,70}${alignr 2}${membar 1,70}${color}${voffset 15}
  ${hr}
  ${hr}
 +
 +
${alignc}${font woodbadge:size=20}Conky${font}
 +
${font woodbadge:size=20}${alignc}Conky${font}
-
===Step 2===
+
'''pvsage said'''
 +
Another way to do it:
 +
1. Above the TEXT area, set a default bar size, e.g. "default_bar_size 50 7" is 50 pixels long, 7 pixels high.
 +
2. Where you want the solid bar, use ${execbar echo 100}
 +
and I tested and found that:
 +
default_bar_size 0 7
 +
TEXT
 +
${execbar echo 100}
 +
created a bar as wide as the conky window with a height of 7
-
[[Image:text-here-2.png|center]]
+
'''''AWESOME!  KUDOS to pvsage.'''''
-
Now you want to “spruce” it up a bit, by adding lines before and after it. It’s easy with the same method used in '''"[[Bars with text (en)|Bars with text]]"''' by using a $cpubar for a CPU you do '''''not''''' have. Easy for me, I don’t have a dual core so anything 1 and above is fine, remember it starts at 0.
+
Now while ''default_bar_size 0 2'' is more or less the same as '''${hr 2}''' ''default_bar_size 50 12'' isn't.
 +
default_bar_size 50 12
 +
TEXT
 +
${alignc}${execbar echo 100}${voffset -1} by pvsage ${voffset 1}${execbar echo 100}
 +
${alignc}${execbar echo 100}${voffset -1} 50    12 ${voffset 1}${execbar echo 100}
-
Now we need to add the code for those “lines” to appear. using a $cpubar command. You’ll need two of them. You can use the same non-existant CPU#, but if memory serves correct conky got confused when it’s used too many times. I may be wrong but just to be sure we’ll use CPU 3 & 4 for this example:
+
Where this differs from ${membar} is ${execbar} does not take height/width parameters only the the default_bar_size can modify it's appearence
-
${hr}
+
[[image:50-12.jpg|center|50-12]]
-
${goto 93}${font woodbadge:size=20}${color2}Conky${color}${font}
+
-
${cpubar cpu3 1,70}${alignr 2}${cpubar cpu4 1,70}
+
-
${hr}
+
-
===Step 3===
+
The last two lines in that code:
-
 
+
  ${alignc}${font woodbadge:size=20}Conky${font}
-
[[Image:text-here-3.png|center]]
+
  ${font woodbadge:size=20}${alignc}Conky${font}
-
 
+
are simply to show, when you use a font and size different to the default font, in this case:
-
Set the “height” to 1 to create the “bar” and 70 for the length. Yours will vary (40, 60 100) depending of the width of your conky display, the text you use and the font. Seems like “spacing” is everywhere in conky. :) I also use (always) ${alignr 2) to bring the output 2 pixels back from the right edge. If it’s a calculated output that changes values it can cause flickering, if it’s “on the edge” and nobody likes a flickering conky, well, nobody I know.
+
-
 
+
-
OK, there’s the bars, now to add ${voffset -xx}, negative xx to move up, until it’s right where you want it.
+
-
 
+
-
  ${hr}
+
-
${goto 93}${font woodbadge:size=20}${color2}Conky${color}${font}
+
-
  ${voffset -25}${cpubar cpu3 1,70}${alignr 2}${cpubar cpu4 1,70}
+
-
${hr}
+
-
 
+
-
See, just like I said, “I can do that.” (I was using a conky version pre v1.8) Now lets go a bit further. Personalize it a bit.
+
-
 
+
-
===Step 4===
+
-
 
+
-
[[Image:text-here-4.png|center]]
+
-
 
+
-
I chose yellow, to match close to the colour of CONKY. “NOT close.” you say. AHHH, but I’m not finished. We are going to “outline” those lines with RED
+
-
 
+
-
To do that copy the line you have producing the “lines” and change the color to “red”, and a ${voffset} to '''-0''' for the moment and change the CPU numbers, I’m using 5 & 6.
+
-
 
+
-
${hr}
+
-
${goto 93}${font woodbadge:size=20}${color2}Conky${color}${font}
+
-
${color yellow}${voffset -25}${cpubar cpu3 1,70}${alignr 2}${cpubar cpu4 1,70}${color}
+
-
${color red}${voffset -0}${cpubar cpu5 1,70}${alignr 2}${cpubar cpu6 1,70}${color}
+
-
${hr}
+
-
 
+
-
===Step 5===
+
-
 
+
-
[[Image:text-here-5.png|center]]
+
-
 
+
-
If you’ve done everything right it should look like the image in the left. Now we have to give RED lines height to outline the YELLOW lines. So change the height to: 4. If you think about it, the top of the CPUBAR is 1 and the bottom is 2, so to have something “around” it you need 2 empty spaces between the top and bottom and x-2=2 is 4-2=2. Simple math.
+
-
 
+
-
${hr}
+
-
${goto 93}${font woodbadge:size=20}${color2}Conky${color}${font}
+
-
${color yellow}${voffset -25}${cpubar cpu3 1,70}${alignr 2}${cpubar cpu4 1,70}${color}
+
-
${color red}${voffset -0}${cpubar cpu5 4,70}${alignr 2}${cpubar cpu6 4,70}${color}
+
-
${hr}
+
-
 
+
-
===Step 6===
+
-
 
+
-
It’s time to play with that ${voffset -0} value, your will vary obviously, mine comes it at ${voffset -27}
+
-
 
+
-
${hr}
+
-
${goto 93}${font woodbadge:size=20}${color2}Conky${color}${font}
+
-
${color yellow}${voffset -25}${cpubar cpu3 1,70}${alignr 2}${cpubar cpu4 1,70}${color}
+
-
${color red}${voffset -27}${cpubar cpu5 4,70}${alignr 2}${cpubar cpu6 4,70}${color}
+
-
${hr}
+
-
 
+
-
[[Image:text-here-6.png|center]]
+
-
 
+
-
And that final code produces the broken ${hr} effect that the user asked about.
+
-
 
+
-
Something conky, earlier than v1.8+, can --'''not'''-- do!
+
-
 
+
-
Happy conkying
+
-
Bruce
+
-
 
+
-
<center>'''WARNING:'''  ''If you are using conky v1.8+ this may not work!''</center>
+
-
 
+
-
===Step 7===
+
-
 
+
-
Well, I assume that it depends on the OS used and maybe what is compiled into Conky because this works on my CrunchBang 10 Statler (based on Debian) with conky v1.8.0
+
-
 
+
-
[[Image:Text-here-7.png|center|thumb|250px]]
+
-
 
+
-
Here is my section after-TEXT:
+
-
 
+
-
TEXT
+
-
${goto 80}${font woodbadge:size=20}${color5}Sector11${color}${font}
+
-
${voffset -23}${cpubar cpu2 5,70}${goto 210}${cpubar cpu2 5,70}
+
-
${voffset -17}${goto 2}${color9}${cpubar cpu2 1,66}${goto 212}${cpubar cpu2 1,66}${color}
+
-
 
+
-
or the full code, if you want it :
+
-
 
+
-
# To use #! in a conky use: ${exec echo '#!'}
+
-
background no
+
-
own_window yes
+
-
own_window_type override #normal
+
-
own_window_transparent yes #yes
+
-
own_window_hints skip_taskbar,skip_pager
+
-
own_window_title test
+
  use_xft yes
  use_xft yes
-
  #xftfont terminus:bold:size=8
+
  xftfont monofur:bold:size=10
-
xftfont DejaVu Sans Mono:size=10
+
it does matter where you put the ${alignc}
-
xftalpha 1.0 #0.2
+
-
override_utf8_locale yes
+
-
update_interval 5
+
-
total_run_times 0
+
-
double_buffer yes
+
-
no_buffers yes
+
-
cpu_avg_samples 2
+
-
net_avg_samples 2
+
-
use_spacer none
+
-
draw_shades no
+
-
draw_outline no
+
-
draw_borders no
+
-
draw_graph_borders no
+
-
uppercase no
+
-
imlib_cache_size 0
+
-
 
+
-
# Colors
+
-
default_color DCDCDC
+
-
color0 FFD700
+
-
color1 FFA07A
+
-
color2 FF8C00
+
-
color3 7FFF00
+
-
color4 778899
+
-
color5 FFDEAD
+
-
color6 00BFFF
+
-
color7 48D1CC
+
-
color8 FFFF00
+
-
color9 FF0000
+
-
 
+
-
text_buffer_size 256 # 256 is the minimum
+
-
short_units yes
+
-
pad_percents 2
+
-
 
+
-
#maximum_width 1280
+
-
#minimum_size 500 110 # width, height
+
-
alignment tl
+
-
gap_x 20 # left-right
+
-
gap_y 20 # up-down
+
-
border_inner_margin 0
+
-
border_outer_margin 0
+
-
 
+
-
TEXT
+
-
${goto 80}${font woodbadge:size=20}${color5}Sector11${color}${font}
+
-
${voffset -23}${cpubar cpu2 5,70}${goto 210}${cpubar cpu2 5,70}
+
-
${voffset -17}${goto 2}${color9}${cpubar cpu2 1,66}${goto 212}${cpubar cpu2 1,66}${color}
+

Latest revision as of 21:05, 26 April 2014

bar-text-bar

 Language   English   Français   


A complete rewrite thanks to some new tricks.

OK so someone asked if it was possible to have:

-- text here --

in conky. Where the was a solid line similar to the ${hr} command.

People started by saying, “No, not possible.” I thought about it for a bit and said to myself, “Yea I can do that!”. With another trick in conky that I have already showed you in "Bars with text inside".

So I set out and experimented and came up with the solution. ${cpubar cpuX} where X is a cpu you do not have. ie: cpu3 for a dual-core

${alignc}${cpubar cpu 5 1,30} cpubar cpuX ${cpubar cpu5 1,30}

as seen in the image on the right.

Fast forward to April 2014 in the CrunchBang Forums

Marenbraga said: I plan to use a bar only as decoration, but I need it filled because of the background color. Any suggestions?

Use: ${membar} with a height no greater than 1 and a width of 0, along with a creative use of font size. Good idea but requires a lot of them to make a real bar

However you can even give it stripes:

Bar-TXT-Bar

The test code that did all that:

default_bar_size 0 12
TEXT
${time %T}${alignr}${time %x}
${alignc}CPU % Usage:
${alignc}1  |  2  |  3  |  A
${alignc}${if_match ${cpu cpu1}<10}00${cpu cpu1}\
${else}${if_match ${cpu cpu1}<100}0${cpu cpu1}\
${else}${color9}${cpu cpu1}${endif}${endif}\
 | ${if_match ${cpu cpu2}<10}00${cpu cpu2}\
${else}${if_match ${cpu cpu2}<100}0${cpu cpu2}\
${else}${color9}${cpu cpu2}${endif}${endif}\
 | ${if_match ${cpu cpu3}<10}00${cpu cpu3}\
${else}${if_match ${cpu cpu3}<100}0${cpu cpu3}\
${else}${color9}${cpu cpu3}${endif}${endif}\
 | ${if_match ${cpu cpu0}<10}00${cpu cpu0}\
${else}${if_match ${cpu cpu0}<100}0${cpu cpu0}\
${else}${cpu cpu0}${endif}${endif}

${alignc}${cpubar cpu4 0,30} cpubar cpu4 ${cpubar cpu4 0,30}
${alignc}${cpubar cpu4 1,30} cpubar cpu4 ${cpubar cpu4 1,30}

${alignc}${membar 1,30} use membar ${membar 1,30}
${font :size=1}${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}
${membar 1,0}${font}
${font :size=1}${color}${membar 1,0}
${membar 1,0}
${membar 1,0}${color blue}
${membar 1,0}
${membar 1,0}${color}
${membar 1,0}
${membar 1,0}${color blue}
${membar 1,0}
${membar 1,0}${color}
${membar 1,0}
${membar 1,0}${color blue}
${membar 1,0}
${membar 1,0}${color}
${membar 1,0}
${membar 1,0}${font}
${alignc}${membar 0,75} Conky PitStop ${membar 0,75}
${membar 0,0}
${alignc}${membar 1,75} Conky PitStop ${membar 1,75}
${membar 1,0}
${alignc}${membar 2,75} Conky PitStop ${membar 2,75}
${membar 3,0}${goto 6}${color red}${membar 1,0}${color}
${membar 2,0}${goto 6}${color blue}${membar 0,0}${color}
${alignc}${membar 1,30} pvsage's idea ${membar 1,30}
${alignc}${membar 1,30} use   execbar ${membar 1,30}
20  ${execbar echo 20}
40  ${execbar echo 40}${goto 150}${voffset -1}${color5}pvsage's idea${color}${voffset 1}
60  ${execbar echo 60}
80  ${execbar echo 80}
100 ${execbar echo 100}${goto 50}${voffset -1}${color 000000}pvsage's idea${color}${voffset 1}
${execbar echo 100}${goto 50}${voffset -1}${color 000000}pvsage's idea${color}${voffset 1}




${alignc}${membar 1,30} pvsage expanded idea ${membar 1,30}
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu}${color}${goto 40}Avg: ${voffset 1}${cpubar cpu0 12}
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu cpu1}${color}${goto 40}  1: ${voffset 1}${cpubar cpu1 12}
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu cpu2}${color}${goto 40}  2: ${voffset 1}${cpubar cpu2 12}
${execbar echo 10}${goto 10}${voffset -1}${color 000000}${cpu cpu3}${color}${goto 40}  3: ${voffset 1}${cpubar cpu3 12}

${hr 10}${goto 20}${voffset 2}${color 000000}and great one too!${color}${voffset -2}

${hr}
${font woodbadge:size=20}${alignc}${color  chocolate}Conky${color}${font}
${color yellow}${voffset -15}${membar 3,70}${alignr 2}${membar 3,70}${color}${voffset 15}
${color red}${voffset -29}${membar 1,70}${alignr 2}${membar 1,70}${color}${voffset 15}
${font woodbadge:size=20}${alignc}${color  chocolate}PitStop${color}${font}
${color yellow}${voffset -15}${membar 3,70}${alignr 2}${membar 3,70}${color}${voffset 15}
${color red}${voffset -29}${membar 1,70}${alignr 2}${membar 1,70}${color}${voffset 15}
${hr}

${alignc}${font woodbadge:size=20}Conky${font}
${font woodbadge:size=20}${alignc}Conky${font}

pvsage said

Another way to do it:
1. Above the TEXT area, set a default bar size, e.g. "default_bar_size 50 7" is 50 pixels long, 7 pixels high.
2. Where you want the solid bar, use ${execbar echo 100}

and I tested and found that:

default_bar_size 0 7
TEXT
${execbar echo 100}

created a bar as wide as the conky window with a height of 7

AWESOME! KUDOS to pvsage.

Now while default_bar_size 0 2 is more or less the same as ${hr 2} default_bar_size 50 12 isn't.

default_bar_size 50 12
TEXT
${alignc}${execbar echo 100}${voffset -1} by pvsage ${voffset 1}${execbar echo 100}
${alignc}${execbar echo 100}${voffset -1} 50     12 ${voffset 1}${execbar echo 100}

Where this differs from ${membar} is ${execbar} does not take height/width parameters only the the default_bar_size can modify it's appearence

50-12

The last two lines in that code:

${alignc}${font woodbadge:size=20}Conky${font}
${font woodbadge:size=20}${alignc}Conky${font}

are simply to show, when you use a font and size different to the default font, in this case:

use_xft yes
xftfont monofur:bold:size=10

it does matter where you put the ${alignc}

Personal tools
Namespaces
Variants
Actions
Navigation
English
Français
Toolbox