You are not logged in.

#1 2023-04-05 08:52:54

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,448

[Solved] Conky, remind, sed and colors

I am trying to get calendar, produced by remind, displayed by conky in color.
Here is my conky config file

conky.config = {
    alignment = 'top_right',
    background = true,
    border_width = 1,
    cpu_avg_samples = 1,
    default_color = 'white',
    default_outline_color = 'black',
    default_shade_color = 'yellow',
    draw_borders = false,
    draw_graph_borders = true,
    draw_outline = false,
    draw_shades = false,
    use_xft = true,
    font = 'NotoSansMono Nerd Font:size=8',
    gap_x = 10,
    gap_y = 10,
    minimum_height = 5,
    minimum_width = 5,
    maximum_width = 550,
    net_avg_samples = 2,
    double_buffer = true,
    out_to_console = false,
    out_to_stderr = false,
    extra_newline = false,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'override',
    own_window_transparent = true,
    own_window_argb_visual = true,
    own_window_argb_value = 140,
    own_window_colour = black,
    stippled_borders = 0,
    update_interval = 3.0,
    uppercase = false,
    use_spacer = 'none',
    show_graph_scale = true,
    override_utf8_locale = true
}

conky.text = [[
${execpi 3600 rem -w,0,0 -m -cu+4 |\
 sed 's/TODAY/${color yellow}TODAY$color/;
 s/Sunday/${color green}SUNDAY$color/;
 s/birthday/${color red}BirthDay$color/g;
 ## s/holiday/${color red}HoliDay$color/g; ## This line fails
 s/wedding anniversary/${color red}Anniversary$color/g;
 s/\*/ /g; '}
$if_mpd_playing ${color orange}${font FontAwesome:bold:size=14}${font Shruti:10}${color}${voffset -4}: $mpd_album $mpd_artist $mpd_title$endif
]]

Sed is used to edit remind output and add some conky commands.
This works mostly, keywords like today/birthday are displayed in color, but somehow whatever I do, word holiday refuses to appear in color. What am I doing wrong here?

Last edited by Docbroke (2023-04-06 06:38:37)

Offline

#2 2023-04-05 09:40:50

dogknowsnx
Guest

Re: [Solved] Conky, remind, sed and colors

What's the unfiltered output of

rem -w,0,0 -m -cu+4

?

EDIT: But please don't post personal information, obviously...

Last edited by dogknowsnx (2023-04-05 09:47:20)

#3 2023-04-05 11:34:01

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,448

Re: [Solved] Conky, remind, sed and colors

Here it is, ( I have just change it to 1 week output only)

$ rem -w,0,0 -m -cu+1
┌──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
│    Monday    │   Tuesday    │  Wednesday   │   Thursday   │    Friday    │   Saturday   │    Sunday    │
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
│3 Apr         │4 Apr         │5 Apr ******* │6 Apr         │7 Apr         │8 Apr         │9 Apr         │
│              │holiday       │TODAY         │POONAM        │holiday Good  │              │              │
│              │Mahavir       │              │              │Friday        │              │              │
│              │Jayanti       │              │ABC's 9th     │              │              │              │
│              │              │              │birthday      │              │              │              │
└──────────────┴──────────────┴──────────────┴──────────────┴──────────────┴──────────────┴──────────────┘

Here is output I am getting from conky at present ( with Holiday line removed)
image.jpg

This is the error I get, when that holiday line is changed with sed

sh: -c: line 1: unexpected EOF while looking for matching `''
sh: -c: line 7: syntax error: unexpected end of file

Error gets corrected if I just remove "${color red}" from holiday line. Now I am using similar line for adding color to birthday/sunday etc. but it fails only when I try to add color to holiday. Also only conky gives error, remind and sed works fine.

This is the output without conky involved, but both remind and sed in use

$ rem -w,0,0 -m -cu+1 | sed 's/TODAY/${color yellow}TODAY$color/;
 s/Sunday/${color green}SUNDAY$color/;
 s/birthday/${color red}BirthDay$color/g;
 s/holiday/${color red}HoliDay$color/g;
 s/wedding anniversary/${color red}Anniversary$color/g;
 s/\*/ /g; '
┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
│  Monday  │ Tuesday  │Wednesday │ Thursday │  Friday  │ Saturday │  ${color green}SUNDAY$color  │
├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
│3 Apr     │4 Apr     │5 Apr     │6 Apr     │7 Apr     │8 Apr     │9 Apr     │
│          │${color red}HoliDay$color   │${color yellow}TODAY$color     │POONAM    │${color red}HoliDay$color   │          │          │
│          │Mahavir   │          │          │Good      │          │          │
│          │Jayanti   │          │ABC's 9th │Friday    │          │          │
│          │          │          │${color red}BirthDay$color  │          │          │          │
└──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┘

So I don't understand why conky don't like "${color red}Holiday$color" but has no problem with "${color red}birthday$color"

Last edited by Docbroke (2023-04-05 11:51:47)

Offline

#4 2023-04-05 12:28:02

dogknowsnx
Guest

Re: [Solved] Conky, remind, sed and colors

What if you defined a red color in your conky config?

EDIT: I'd have to agree with conky, though - holidays shouldn't be red tongue
EDIT#2: Also, how do you feed 'remind' and with what kind of data/format? Config files?

Last edited by dogknowsnx (2023-04-05 12:43:58)

#5 2023-04-05 13:11:08

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,448

Re: [Solved] Conky, remind, sed and colors

Red is just an example, any color I put there it doesn't work with holidays. Btw., red works just fine with birthday, so red is probably not an issue.

Here is main remind input file

$ cat .config/remind/reminder.rem
BANNER %
include .config/remind/default.rem
include .config/remind/birthdays.rem
include .config/remind/holidays.rem

holidays.rem contains list of holidays, here is a short example

$ cat .config/remind/holidays.rem

OMIT 14 Jan +10 MSG [Ylw]%"holiday MakarSankranti%"[Nrm] %v
OMIT 26 Jan +10 MSG [Ylw]%"holiday Republic Day%"[Nrm] %v
OMIT 24 Mar +10 MSG [Ylw]%"holiday World TB Day%"[Nrm] %v

Similarly birthday is list of birthdays, and other random stuff goes in default

Offline

#6 2023-04-05 13:39:43

dogknowsnx
Guest

Re: [Solved] Conky, remind, sed and colors

So you're using different formats in the other '.rem' config files? Did you try double quotes with sed (not very well versed in sed on my part...)?

#7 2023-04-05 14:19:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Conky, remind, sed and colors

Double quotes obviously wouldn't work - at least not without a lot of gymnastics to escape all the '$' signs.

Rem and sed really aren't relevant as they are working fine - the problem is with how conky is interpreting that output.  If it were me - as a diagnostic test - I'd run the rem/sed command and direct the output to a file, then cat that file from your conky config.  If this fails you may get better error information about exactly what part of that file/output was the problem, and it'd be easier to adjust that temporary file to figure out which exact character (or sequence) conky has a problem with.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2023-04-06 06:09:06

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,448

Re: [Solved] Conky, remind, sed and colors

Hi Trilby, I tried to push the rem output using cat as you suggested. It failed with same error as I have posted above (unexpected EOF). So I removed sed lines step by step, ultimately removing all sed lines, still same error. Now it appears that if I use "rem -w,0,0 -m -cu+1" with conky, it works, but if I input output of same command using cat or echo it fails with same error (unexpected EOF while looking for matching ')

EDIT: I have already posted output of "rem -w,0,0 -m -cu+1" in 3rd post of this thread, as well as my entire conky config in first post.

EDIT: forget what is written above, I actually missed to use file as an output. After directing output to a file and then feeding it to conky gives no error.  So I solved this by running a shellscript from conky which runs rem/sed and feeds output to conky, instead of running command directly from conky.

Thanks all.

Last edited by Docbroke (2023-04-06 06:38:12)

Offline

#9 2023-04-06 12:08:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Conky, remind, sed and colors

Then the error comes from conky's parsing of the command before it is sent to the shell.  I gather conky replaced all the ${..} color codes before passing that command to the shell, and one of those color codes in turn broke the sed command.  Theoretically this could be avoided by escaping the '$' symbols, but using a script is likely easier.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#10 2023-04-06 17:56:19

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,448

Re: [Solved] Conky, remind, sed and colors

That may be true.
What is surprising here is, These lines work

s/Sunday/${color green}SUNDAY$color/;
 s/birthday/${color red}BirthDay$color/g;

BUT this doesn't

s/holiday/${color red}HoliDay$color/g;

Offline

#11 2023-04-06 20:21:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Conky, remind, sed and colors

That depends what "${color red}" is replaced with.  Context matters.  For example, an escape character followed by an H is different from that same escape character followed by an S or B.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB