Files
_dotfiles/.config/i3blocks/openvpn-systemd/openvpn-systemd
2024-06-12 13:49:42 +02:00

24 lines
462 B
Perl
Executable File

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use JSON::Parse 'parse_json';
my $units = parse_json(`systemctl list-units --output=json --state=active 'openvpn-client@*'`);
if (@$units) {
my @names = sort map {
$_->{unit} =~ /^openvpn-client@(.*)\.service$/;
$1;
} @$units;
print join(' ', @names) . "\n";
print "up\n";
print "#00FF00\n";
} else {
print "down\n";
print "down\n";
print "#FF0000\n";
}