davatorium / rofi

Rofi: A window switcher, application launcher and dmenu replacement
https://davatorium.github.io/rofi/
Other
13.29k stars 613 forks source link

markup doesn't show when run from i3blocks #669

Closed vKnmnn closed 7 years ago

vKnmnn commented 7 years ago

Version

Version: 1.3.1 - 1.3.1-692-gf62216fa (master) Version: 1.3.1 - 1.3.1-692-gf62216fa (master)

Steps to reproduce

create block in i3blocks

[date]
label=
command=/home/abc/.config/i3blocks/blocklets/date-cal
interval=3000

date-cal looks like this:

#! /bin/sh

date=$(date '+%a. %d. %b. %Y')

case "$BLOCK_BUTTON" in
    1|2|3) ~/.config/i3blocks/blocklets/rofi-cal.sh >/dev/null 
esac

echo $date
date '+%d.%m.%Y'

finally, rofi-cal looks like this:

#! /bin/sh

date=$(date '+%A, %d. %B')
#EDIT put fix in here for future reference
export TERM=xterm
# end fix
cal --color=always \
    | sed 's/\x1b\[[7;]*m/\<b\>\<u\>/g' \
    | sed 's/\x1b\[[27;]*m/\<\/u\>\<\/b\>/g' \
    | tail -n +2 \
    | rofi \
        -dmenu \
        -markup-rows \
        -no-fullscreen \
        -font "Monospace 6" \
        -hide-scrollbar \
        -bw 2 \
        -m -3 \
        -theme-str '#window {anchor:southeast; location: northwest;}' \
        -eh 1 \
        -width -22 \
        -no-custom \
        -p "$date" \
        -mesg "test <u><b>test</b></u>"

What behaviour you see

What behaviour you expect to see

sardemff7 commented 7 years ago

Could you check the whole env in both cases, and what is actually passed to rofi in both cases? A simple way is to add | tee /tmp/rofi-stuff in your pipe and copy /tmp/rofi-stuff after each call.

vKnmnn commented 7 years ago

As suspected, the output given to rofi via the block does not contain the markup. as it seems, the cal --color=always command is not executed properly. forcing color output via /etc/terminal-colors.d/cal.enable doesn't change this behaviour.

edit: diff'ing both env's shows a few things not set for the block. Those are: EDITOR VTE_VERSION=4803 LS_COLORS=loads of stuff TERM=xterm-256color COLORTERM=truecolor VISUAL=vim

and setting those manually in the script doesn't change anything

the man-page of cal states, that color is enabled by default

vKnmnn commented 7 years ago

can you reproduce this?

DaveDavenport commented 7 years ago

cal for me does not have the color option? what program (link) are you running?

(p.s. this might be interesting, it has an option to output pango markup: https://github.com/DaveDavenport/out2html. )

sardemff7 commented 7 years ago

TERM is the one, I guess it uses it to detect ANSI codes support. I would set it to vt100 to get the smallest (?) set.

vKnmnn commented 7 years ago

i use cal from util-linux 2.30.1-2, it's part of coreutils (in arch)

putting export TERM=xterm into the script produces the expected behaviour, whereas vt100 breaks things even further. weird though, that TERM=xterm-256color does not work.

DaveDavenport commented 7 years ago

This is the difference:

TERM=xterm tty-pipe ncal | hexdump -c
0000000                   S   e   p   t   e   m   b   e   r       2   0
0000010   1   7                  \n   m   a                       4    
0000020 033   [   7   m   1   1 033   [   2   7   m       1   8       2
0000030   5              \n   d   i                       5       1   2
0000040       1   9       2   6              \n   w   o                
0000050       6       1   3       2   0       2   7              \n   d
0000060   o                       7       1   4       2   1       2   8
0000070              \n   v   r           1           8       1   5    
0000080   2   2       2   9              \n   z   a           2        
0000090   9       1   6       2   3       3   0              \n   z   o
00000a0           3       1   0       1   7       2   4                
00000b0          \n                                                    
00000b3
TERM=xterm-256 tty-pipe ncal | hexdump -c
0000000                   S   e   p   t   e   m   b   e   r       2   0
0000010   1   7                  \n   m   a                       4    
0000020   _  \b   1   _  \b   1       1   8       2   5              \n
0000030   d   i                       5       1   2       1   9       2
0000040   6              \n   w   o                       6       1   3
0000050       2   0       2   7              \n   d   o                
0000060       7       1   4       2   1       2   8              \n   v
0000070   r           1           8       1   5       2   2       2   9
0000080              \n   z   a           2           9       1   6    
0000090   2   3       3   0              \n   z   o           3       1
00000a0   0       1   7       2   4                          \n        
vKnmnn commented 7 years ago

I see. i consider this not-a-bug, so this will be closed. Thanks for your support

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.