summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-31 21:03:26 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-31 21:03:26 -0700
commit7a541bf49cf5bfc538ccafa5433aace5c8522f8c (patch)
tree2a43a59776390b024bea68f88396c735cc7fc36e /scripts
parent6d23ff4b88d8fbb05f037b5b4e1cf6ade55b6a64 (diff)
downloaddotfiles-7a541bf49cf5bfc538ccafa5433aace5c8522f8c.tar.gz
handle lack of i3-msg on PATH in a few places
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/desktop/fresh-workspace9
-rwxr-xr-xscripts/desktop/i3status-wrapper5
2 files changed, 10 insertions, 4 deletions
diff --git a/scripts/desktop/fresh-workspace b/scripts/desktop/fresh-workspace
index a34205d3..7251ed07 100755
--- a/scripts/desktop/fresh-workspace
+++ b/scripts/desktop/fresh-workspace
@@ -13,8 +13,11 @@ my @all_workspaces = (
"19:F9", "20:F10", "21:F11", "22:F12"
);
+`which i3-msg`;
+my $exec = $? == 0 ? "i3-msg" : "swaymsg";
+
my %current_names = map +($_->{name}, undef),
- @{ decode_json `i3-msg -t get_workspaces` };
+ @{ decode_json `$exec -t get_workspaces` };
my $next_free_workspace
= first { not exists $current_names{$_} } @all_workspaces;
@@ -26,13 +29,13 @@ if ($next_free_workspace) {
# other wanted containers over there, before finally switching
# the view with 'workspace back_and_forth'
system
- "i3-msg move container to workspace $next_free_workspace"
+ "$exec move container to workspace $next_free_workspace"
# Only the first of the three commands within this call to i3-msg
# should be necessary, but we need the others to work around
# https://github.com/swaywm/sway/issues/6081
.", workspace $next_free_workspace, workspace back_and_forth >/dev/null";
} else {
- system "i3-msg workspace $next_free_workspace >/dev/null";
+ system "$exec workspace $next_free_workspace >/dev/null";
}
}
diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper
index fffde8d1..cbe02685 100755
--- a/scripts/desktop/i3status-wrapper
+++ b/scripts/desktop/i3status-wrapper
@@ -33,6 +33,9 @@ my $caffeinated;
my $username = $ENV{LOGNAME} || $ENV{USER} || getpwuid($<);
my $hostname = hostname;
+`which i3-msg`;
+my $exec = $? == 0 ? "i3-msg" : "swaymsg";
+
expensive();
$SIG{USR1} = sub { kill USR1 => $i3status; expensive() };
@@ -52,7 +55,7 @@ while (my ($statusline) = (<$pipe> =~ /^,?(.*)/)) {
sub expensive {
my %marks;
- walk_tree(\%marks, decode_json `i3-msg -t get_tree`);
+ walk_tree(\%marks, decode_json `$exec -t get_tree`);
$caffeinated = exists $marks{caffeinated} ? $marks{caffeinated} : undef;
}