diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-08 14:45:33 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-08 14:45:33 -0700 |
commit | 68ec754d8c5953532a39a69b8ca11d9dd4d724a0 (patch) | |
tree | b1a1248fb48b471e96db469fdc4cc790ee6bdfad /scripts | |
parent | fab048f960665a2d88658e329343c30685e5af32 (diff) | |
download | dotfiles-68ec754d8c5953532a39a69b8ca11d9dd4d724a0.tar.gz |
i3status-wrapper: start i3status ourselves
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/desktop/i3status-wrapper | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper index 7e518666..2b891591 100755 --- a/scripts/desktop/i3status-wrapper +++ b/scripts/desktop/i3status-wrapper @@ -17,22 +17,33 @@ use warnings; # libjson-perl on Debian/Ubuntu. use JSON; +use IO::Pipe; use Sys::Hostname; # Don’t buffer any output. $| = 1; +my $pipe = IO::Pipe->new; +my $i3status = fork // die "couldn't fork()!"; +unless ($i3status) { + $pipe->writer; + open STDOUT, ">&=", $pipe->fileno + or die "couldn't open child's STDOUT"; + exec "i3status"; +} +$pipe->reader; + # Skip the first line which contains the version header. -print scalar <STDIN>; +print scalar <$pipe>; # The second line contains the start of the infinite array. -print scalar <STDIN>; +print scalar <$pipe>; my $username = $ENV{LOGNAME} || $ENV{USER} || getpwuid($<); my $hostname = hostname; # Read lines forever, ignore a comma at the beginning if it exists. -while (my ($statusline) = (<STDIN> =~ /^,?(.*)/)) { +while (my ($statusline) = (<$pipe> =~ /^,?(.*)/)) { # Decode the JSON-encoded line. my @blocks = @{decode_json($statusline)}; |