Skip to content

Commit

Permalink
Quality of life fixes for Haiku
Browse files Browse the repository at this point in the history
Unlike a normal Linux/Unix system, there's really no global ENV unless you launch the application from a terminal.
Doh.
  • Loading branch information
zdykstra committed Dec 30, 2020
1 parent ca9fc0a commit d0a7296
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions tmuxc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env perl
#!/bin/perl

use strict;
use warnings;
Expand Down Expand Up @@ -40,20 +40,32 @@ my (
);

# Looking for configs in all the right places
my @configtests = (
join( '/', ( $ENV{'HOME'}, qw(.tmuxc.conf) ) ),
join( '/', ( $ENV{'HOME'}, qw(.config/tmuxc.conf) ) ),
join( '/', ( $ENV{'HOME'}, qw(.config/tmuxc/tmuxc.conf) ) ),
);
my @configtests;

use Config;
if ($Config{osname} eq "haiku") {
push(@configtests, "/boot/home/config/settings");
}

if ( defined( $ENV{'HOME'} ) ) {
push(@configtests, join( '/', ( $ENV{'HOME'}, qw(.tmuxc.conf) ) ) );
push(@configtests, join( '/', ( $ENV{'HOME'}, qw(.config/tmuxc.conf) ) ) );
push(@configtests, join( '/', ( $ENV{'HOME'}, qw(.config/tmuxc/tmuxc.conf) ) ) );
}

if ( defined( $ENV{'XDG_CONFIG_HOME'} ) ) {
push(@configtests, join( '/', ( $ENV{'XDG_CONFIG_HOME'}, qw( tmuxc.settings) ) ) );
}

foreach (@configtests) {
if (-f) {
$configfile = $_;
if ( scalar @configtests > 0 ) {
foreach (@configtests) {
if (-f) {
$configfile = $_;
}
}
} else {
print "Unable to find a configuration file\n";
exit;
}

unless ( length $configfile ) {
Expand Down Expand Up @@ -585,8 +597,8 @@ fi
END {
exit if $noclean;

if ( ( $config->{poe} eq "any" )
or ( $config->{ephemeral} and $config->{poe} eq "ephemeral" ) )
if ( ( exists $config->{poe} and $config->{poe} eq "any" )
or ( ( exists $config->{ephemeral} and $config->{ephemeral} ) and ( exists $config->{poe} and $config->{poe} eq "ephemeral" ) ) )
{
my @cmd = buildCommand( $host, [ $config->{tmux_bin}, qw(kill-session -t), $config->{session}, ] );
Log( LOG_DEBUG, "Killing session $config->{session}" );
Expand All @@ -604,8 +616,14 @@ END {
sub CleanExit {
exit if $noclean;

unlink $config->{command};
unlink $config->{pidfile};
if ( exists $config->{command} ) {
unlink $config->{command};
}

if ( exists $config->{pidfile} ) {
unlink $config->{pidfile};
}

exit;
}

Expand Down

0 comments on commit d0a7296

Please sign in to comment.