ashish-yadav11 / dwmblocks

Rewrite of dwmblocks with added features including clickability, cursor hinting and color.
ISC License
212 stars 30 forks source link

Strange glitchy character appearing between blocks #7

Closed rensenware closed 4 years ago

rensenware commented 4 years ago

glitchy

I apologize if this isn't the correct place to ask this. I am setting this up and currently have 2 blocks, battery-combined-udev and time. In my dwm config, I have the fonts Iosevka and Font Awesome 5 Pro Regular defined and they both work correctly. In between the two blocks I set up, a strange character is appearing right before the time block. My blocks.h:

/* time interval in seconds to sleep before looking for updates in the main loop */
#define SLEEPINTERVAL                   1

#define PATH(name)                      "/home/rensenware/.config/scripts/"name

/* If interval of a block is set to 0, the block will only be updated once at startup.
 * If interval is set to a negative value, the block will never be updated in the main loop.
 * Set signal to 0 if signalling is not required for the block.
 * Signal must be less than 10 for clickable blocks.
 * If multiple realtime signals are pending, then the lowest numbered signal is delivered first. */

/* pathu - path of the program whose output is to be used for status text
 * pathc - path of the program to be executed on clicks */
static Block blocks[] = {
/*      pathu              pathc                interval                signal */
        { PATH("battery-combined-udev.sh"),NULL,0,                      2},
        { PATH("time.sh"), NULL,                1,                      0},

        { NULL } /* just to mark the end of the array */
};

static const char *delim =  "  ";

My time.sh module:

#!/bin/sh

icon=

cmd=$(date +"%a %Y-%m-%d  %H:%M")

echo "$icon $cmd"

My battery module:

#!/bin/sh

battery_print() {
    PATH_AC="/sys/class/power_supply/AC"
    PATH_BATTERY_0="/sys/class/power_supply/BAT0"
    PATH_BATTERY_1="/sys/class/power_supply/BAT1"

    ac=0
    battery_level_0=0
    battery_level_1=0
    battery_max_0=0
    battery_max_1=0

    if [ -f "$PATH_AC/online" ]; then
        ac=$(cat "$PATH_AC/online")
    fi

    if [ -f "$PATH_BATTERY_0/energy_now" ]; then
        battery_level_0=$(cat "$PATH_BATTERY_0/energy_now")
    fi

    if [ -f "$PATH_BATTERY_0/energy_full" ]; then
        battery_max_0=$(cat "$PATH_BATTERY_0/energy_full")
    fi

    if [ -f "$PATH_BATTERY_1/energy_now" ]; then
        battery_level_1=$(cat "$PATH_BATTERY_1/energy_now")
    fi

    if [ -f "$PATH_BATTERY_1/energy_full" ]; then
        battery_max_1=$(cat "$PATH_BATTERY_1/energy_full")
    fi

    battery_level=$(("$battery_level_0 + $battery_level_1"))
    battery_max=$(("$battery_max_0 + $battery_max_1"))

    battery_percent=$(("$battery_level * 100"))
    battery_percent=$(("$battery_percent / $battery_max"))

    if [ "$ac" -eq 1 ]; then
        icon=""

    echo "$icon  $battery_percent%"
    else
        if [ "$battery_percent" -gt 90 ]; then
            icon=""
        elif [ "$battery_percent" -gt 74 ]; then
            icon=""
        elif [ "$battery_percent" -gt 49 ]; then
            icon=""
        elif [ "$battery_percent" -gt 24 ]; then
            icon=""
        else
            icon=""
        fi

        echo "$icon  $battery_percent%"
    fi
}

path_pid="/tmp/polybar-battery-combined-udev.pid"

case "$1" in
    --update)
        pid=$(cat $path_pid)

        if [ "$pid" != "" ]; then
            kill -10 "$pid"
        fi
        ;;
    *)
        echo $$ > $path_pid

        trap exit INT
        trap "echo" USR1

        while true; do
            battery_print

            sleep 30 &
            wait
        done
        ;;
esac

Let me know if any more information is required.

ashish-yadav11 commented 4 years ago

Have you applied the dwm patch in the patches folder? Also does that character appear even if you remove the icons from the scripts or with icons other than what you are currently using?

rensenware commented 4 years ago

I hadn't applied the patches, no, I'll try that now. Is the systray patch just for if I wanted a systray and unnecessary otherwise?

rensenware commented 4 years ago

It appears even when I disable the icons.

ashish-yadav11 commented 4 years ago

Yes, the systray patch is for dwm already patched with systray, the other patch is for dwm without the systray patch. You can read the readme for more info.

The problem occured since you didn't apply the patch. So closing the issue.

ashish-yadav11 commented 4 years ago

If you don't want the features of clickability, color and cursor hinting, torrinfail's dwmblocks might be more suited for your usecase.

rensenware commented 4 years ago

Looks like it is, thanks for your help.