Skip to content

Instantly share code, notes, and snippets.

@steadystatic
Last active September 10, 2018 20:28
Show Gist options
  • Save steadystatic/5c0bb0f63a73528ecef40614b135f135 to your computer and use it in GitHub Desktop.
Save steadystatic/5c0bb0f63a73528ecef40614b135f135 to your computer and use it in GitHub Desktop.
Check vpnc pid file and print online or offline indicator
#!/usr/bin/perl
#
# VPN pid checker to report online or offline in emoji
#
# Used in tmux prompt so...
# a. No warnings desired
no warnings;
# b. Need to output utf8 for terminal
binmode(STDOUT, ":utf8");
# Location of vpnc's pid file when openconnect script started as background daemon
$vpn_pid = '/var/run/vpnc/vpnc.pid';
$result = "\x{02705}";
if (!-f $vpn_pid) {
$result = "\x{026D4}";
}
print STDOUT $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment