Created
February 5, 2015 18:51
-
-
Save Tucos/1491ae06270fd7d52ac7 to your computer and use it in GitHub Desktop.
Non-latin detection in conky variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
out_to_x no | |
out_to_console yes | |
TEXT | |
${if_match "${eval $${exec ./script.sh '${time %A}'}}" == "latin"}boring${else}exciting!${endif} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
latin=$(echo -n "${1}" | od -w1000 -t x1 | awk ' | |
{ | |
for (i = 2; i <= NF; i++) { | |
n = "0x" $i | |
if (strtonum(n) > 0x7F) { | |
print "n"; | |
exit; | |
} | |
} | |
}') | |
if test -z "$latin"; then | |
echo -n 'latin' | |
else | |
echo -n 'nonlatin' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment