vlevit / notify-send.sh

drop-in replacement for notify-send with more features
GNU General Public License v3.0
282 stars 40 forks source link

Fixed locale issue inside sleep command #22

Closed Luigi-98 closed 3 years ago

Luigi-98 commented 3 years ago

Problem

I'm from Italy, here we write float numbers in a different way: we use commas to divide the integer and decimal parts, like 5,04 instead of the standard 5.04.

The sleep command won't work when given numbers in this format and will raise an error like this:

$ sleep 5,04
sleep: invalid time interval ‘5,04’
Try 'sleep --help' for more information.
$ 

Same will be raised when calling ./notify-send.sh -t 5040 -f Test, because sleep 5,04 will be internally called. That number is computed using the printf command, which gives different output with different locales.

My solution

I added a locale change within the internal call to the printf command: LC_NUMERIC='en_US.UTF-8' printf %f "${EXPIRE_TIME}e-3

M3TIOR commented 3 years ago

That's a great fix, for a niche but valid problem I didn't even think about. I'll have to add that to my fork! Thanks! 👍🏻

vlevit commented 3 years ago

Thank you @Luigi-98 and @PhrozenByte