UtkarshVerma / dwmblocks-async

An efficient, lean, and asynchronous status feed generator for dwm.
GNU General Public License v2.0
224 stars 87 forks source link

show a text for an amount of time when button is pressed, then show another default text #58

Closed Mohamed-Fathy-Salah closed 6 months ago

Mohamed-Fathy-Salah commented 7 months ago

When date block is pressed, it should print the output of date "+%a %d %b " on the status bar for 3 seconds then it should print the date sybmol. however it prints the output of date "+%a %d %b " only. image

UtkarshVerma commented 6 months ago

You got the logic correct for the most part. What you missed is to fork the kill command. This is because dwmblocks waits for the current execution to complete and then reads the output.

Here's how you would do this.

#!/bin/sh

case $BLOCK_BUTTON in
    1)
        echo "A"
        (sleep 3 && pkill -RTMIN+10 dwmblocks) &
        ;;
    *) echo "B" ;;
esac
Mohamed-Fathy-Salah commented 6 months ago

When it gets pressed, It waits for 3 seconds, then it shows the second text. However it should show the second text for 3 seconds, then the first text again.

Mohamed-Fathy-Salah commented 6 months ago

It got solved using sesid

#!/bin/sh

case $BLOCK_BUTTON in
    1) 
        setsid -f bash -c 'sleep 3 && kill -35 $(pidof dwmblocks)' >/dev/null 2>&1
        date "+%a %d %b " ;;
    *) echo '';;
esac