diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-08-01 00:28:48 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-08-01 00:28:48 -0400 |
commit | 078e1c69b836ab2c4c671488764da78750c3c02f (patch) | |
tree | 22159bf415e4d8eb75800fe459fae4386c98d03a /bin | |
parent | d3386cd884d5b54b70afbe0513796439eb33674e (diff) | |
download | conf-078e1c69b836ab2c4c671488764da78750c3c02f.tar.gz conf-078e1c69b836ab2c4c671488764da78750c3c02f.zip |
add scripts to switch a workspace between a virtual screen
this keeps it rendering even while offscreen so obs works correctly
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/hush/i3-switch-workspace | 31 | ||||
-rwxr-xr-x | bin/hush/vscreen | 17 |
2 files changed, 41 insertions, 7 deletions
diff --git a/bin/hush/i3-switch-workspace b/bin/hush/i3-switch-workspace index acae465..b54afa1 100755 --- a/bin/hush/i3-switch-workspace +++ b/bin/hush/i3-switch-workspace @@ -8,6 +8,8 @@ use JSON::PP; my $json = JSON::PP->new; +my $virtual_workspace = 'virtual'; + my %message_types = ( command => 0, get_workspaces => 1, @@ -32,11 +34,17 @@ my $tree_data = $json->decode(i3_msg('get_tree')); my $first = 99999; my $last = -99999; my $cur; +my $cur_name; +my $virtual_output; for my $i (0..$#$workspace_data) { my $num = $workspace_data->[$i]{num}; if ($workspace_data->[$i]{focused}) { $cur = $num; + $cur_name = $workspace_data->[$i]{name}; + if ($cur_name eq $virtual_workspace) { + $virtual_output = $workspace_data->[$i]{output}; + } } my $workspace_tree = find_workspace($tree_data, $num); @@ -48,25 +56,34 @@ for my $i (0..$#$workspace_data) { $last = $num if $num > $last; } -my $to; if ($dir eq 'prev') { if ($cur >= $first) { - $to = $cur - 1; + i3_msg('command', "workspace ${\($cur - 1)}"); } } elsif ($dir eq 'next') { if ($cur <= $last) { - $to = $cur + 1; + i3_msg('command', "workspace ${\($cur + 1)}"); + } +} +elsif ($dir eq $virtual_workspace) { + if (!defined $virtual_output || $virtual_output eq 'VIRTUAL1') { + i3_msg( + 'command', + "workspace $virtual_workspace; move workspace to output eDP1", + ); + } + else { + i3_msg( + 'command', + "workspace $virtual_workspace; move workspace to output VIRTUAL1", + ); } } else { die "unknown subcommand $dir"; } -if (defined $to) { - i3_msg('command', "workspace $to"); -} - sub find_workspace { my ($tree, $num) = @_; if (exists $tree->{num} && $tree->{num} == $num) { diff --git a/bin/hush/vscreen b/bin/hush/vscreen new file mode 100755 index 0000000..d39b389 --- /dev/null +++ b/bin/hush/vscreen @@ -0,0 +1,17 @@ +#!/bin/sh + + +case "$1" in + goto) + xrandr --addmode VIRTUAL1 1920x1080 + xrandr --output VIRTUAL1 --auto --output eDP1 --auto --left-of VIRTUAL1 + i3-switch-workspace virtual + ;; + off) + xrandr --output VIRTUAL1 --off + ;; + *) + echo "bad subcommand $1" >&2 + exit 1 + ;; +esac |