Skip to content

Instantly share code, notes, and snippets.

@Tucos
Created February 5, 2015 18:51
Show Gist options
  • Save Tucos/1491ae06270fd7d52ac7 to your computer and use it in GitHub Desktop.
Save Tucos/1491ae06270fd7d52ac7 to your computer and use it in GitHub Desktop.
Non-latin detection in conky variables
out_to_x no
out_to_console yes
TEXT
${if_match "${eval $${exec ./script.sh '${time %A}'}}" == "latin"}boring${else}exciting!${endif}
#!/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