summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-03-08 14:45:33 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-03-08 14:45:33 -0700
commit68ec754d8c5953532a39a69b8ca11d9dd4d724a0 (patch)
treeb1a1248fb48b471e96db469fdc4cc790ee6bdfad /scripts
parentfab048f960665a2d88658e329343c30685e5af32 (diff)
downloaddotfiles-68ec754d8c5953532a39a69b8ca11d9dd4d724a0.tar.gz
i3status-wrapper: start i3status ourselves
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/desktop/i3status-wrapper17
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)};