diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-15 14:31:32 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-15 14:31:32 +0200 |
commit | ebad0a066f2814abae9563f050a4f5c62e3251f6 (patch) | |
tree | 5205d9bc006acf367d274c037e13e1dcd0f1d244 /.config/bspwm/terms_thread.pl | |
parent | diff (diff) | |
download | dotfiles-bsd-ebad0a066f2814abae9563f050a4f5c62e3251f6.tar.gz dotfiles-bsd-ebad0a066f2814abae9563f050a4f5c62e3251f6.tar.bz2 dotfiles-bsd-ebad0a066f2814abae9563f050a4f5c62e3251f6.tar.xz dotfiles-bsd-ebad0a066f2814abae9563f050a4f5c62e3251f6.tar.zst dotfiles-bsd-ebad0a066f2814abae9563f050a4f5c62e3251f6.zip |
Threaded bspwm
Diffstat (limited to '')
-rwxr-xr-x | .config/bspwm/terms_thread.pl | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/.config/bspwm/terms_thread.pl b/.config/bspwm/terms_thread.pl new file mode 100755 index 0000000..4d6e9ed --- /dev/null +++ b/.config/bspwm/terms_thread.pl @@ -0,0 +1,182 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use Time::HiRes; + +use constant { + BSPC_PATH => '/usr/local/bin/bspc', + ESPEAK_PATH => '/usr/local/bin/espeak', + ALACRITTY_PATH => '/usr/local/bin/alacritty', + SH_PATH => '/bin/sh', + ZSH_PATH => '/usr/local/bin/zsh', + COWSAY_PATH => '/usr/local/bin/cowsay', + HTOP_PATH => '/usr/local/bin/htop', + GOTOP_PATH => '/usr/local/bin/gotop', + VIFM_PATH => '/usr/local/bin/vifm' +}; +use constant COWSAY_WELCOME => 'Welcome back, partner! And remember to try glest!'; + +sub run_espeak +{ + my $espeak_pid; + + $espeak_pid = fork(); + if (not $espeak_pid) { + exec(ESPEAK_PATH, COWSAY_WELCOME); + } + return; +} + +sub fg_on_three_screens +{ + my @term_pid; + + $term_pid[0] = fork(); + if (not $term_pid[0]) { + exec( + ALACRITTY_PATH, '-e', SH_PATH, '-c', + COWSAY_PATH . ' "' . COWSAY_WELCOME . '"; ' . ZSH_PATH + ); + exit; + } + Time::HiRes::sleep(2.5); + $term_pid[1] = fork(); + if (not $term_pid[1]) { + exec(ALACRITTY_PATH, '-e', HTOP_PATH); + exit; + } + Time::HiRes::sleep(2.5); + $term_pid[2] = fork(); + if (not $term_pid[2]) { + exec(ALACRITTY_PATH, '-e', GOTOP_PATH); + exit; + } + Time::HiRes::sleep(2.5); + system(BSPC_PATH, 'node', '-f', 'west'); + $term_pid[3] = fork(); + if (not $term_pid[3]) { + exec(ALACRITTY_PATH, '-e', VIFM_PATH); + exit; + } + Time::HiRes::sleep(2.5); + system(BSPC_PATH, 'node', '-z', 'right', '180', '0'); + system(BSPC_PATH, 'node', '-z', 'top', '0', '70'); + system(BSPC_PATH, 'node', '-f', 'east'); + system(BSPC_PATH, 'node', '-f', 'north'); + system(BSPC_PATH, 'node', '-z', 'bottom', '0', '-280'); + system(BSPC_PATH, 'node', '-f', 'north'); + system(BSPC_PATH, 'node', '-f', 'west'); + return; +} + +sub fg_on_two_screens +{ + my @term_pid; + + $term_pid[0] = fork(); + if (not $term_pid[0]) { + exec( + ALACRITTY_PATH, '-e', SH_PATH, '-c', + COWSAY_PATH . ' "' . COWSAY_WELCOME . '"; ' . ZSH_PATH + ); + exit; + } + Time::HiRes::sleep(2.5); + $term_pid[1] = fork(); + if (not $term_pid[1]) { + exec(ALACRITTY_PATH, '-e', HTOP_PATH); + exit; + } + Time::HiRes::sleep(2.5); + $term_pid[2] = fork(); + if (not $term_pid[2]) { + exec(ALACRITTY_PATH, '-e', GOTOP_PATH); + exit; + } + Time::HiRes::sleep(2.5); + system(BSPC_PATH, 'node', '-f', 'west'); + $term_pid[3] = fork(); + if (not $term_pid[3]) { + exec(ALACRITTY_PATH, '-e', VIFM_PATH); + exit; + } + Time::HiRes::sleep(2.5); + system(BSPC_PATH, 'node', '-z', 'right', '180', '0'); + system(BSPC_PATH, 'node', '-z', 'top', '0', '70'); + system(BSPC_PATH, 'node', '-f', 'east'); + system(BSPC_PATH, 'node', '-f', 'north'); + system(BSPC_PATH, 'node', '-z', 'bottom', '0', '-280'); + system(BSPC_PATH, 'node', '-f', 'north'); + system(BSPC_PATH, 'node', '-f', 'west'); + return; +} + +sub fg_on_one_screen +{ + my @term_pid; + + $term_pid[0] = fork(); + if (not $term_pid[0]) { + exec( + ALACRITTY_PATH, '-e', SH_PATH, '-c', + COWSAY_PATH . ' "' . COWSAY_WELCOME . '"; ' . ZSH_PATH + ); + exit; + } + Time::HiRes::sleep(2.5); + system(BSPC_PATH, 'node', '-p', 'west'); + $term_pid[1] = fork(); + if (not $term_pid[1]) { + exec(ALACRITTY_PATH, '-e', HTOP_PATH); + exit; + } + Time::HiRes::sleep(2.5); + $term_pid[2] = fork(); + if (not $term_pid[2]) { + exec(ALACRITTY_PATH, '-e', GOTOP_PATH); + } + Time::HiRes::sleep(2.5); + system(BSPC_PATH, 'node', '-f', 'east'); + $term_pid[3] = fork(); + if (not $term_pid[3]) { + exec(ALACRITTY_PATH, '-e', VIFM_PATH); + } + Time::HiRes::sleep(2.5); + system(BSPC_PATH, 'node', '-f', 'west'); + system(BSPC_PATH, 'node', '-f', 'north'); + system(BSPC_PATH, 'node', '-z', 'bottom', '0', '-200'); + system(BSPC_PATH, 'node', '-z', 'right', '-220', '0'); + system(BSPC_PATH, 'node', '-f', 'east'); + system(BSPC_PATH, 'node', '-z', 'bottom', '0', '70'); + system(BSPC_PATH, 'node', '-f', 'north'); + return; +} + +sub run_terms +{ + my ($screens) = @_; + + system(BSPC_PATH, 'desktop', '-f', '09'); + if ($screens == 3) { + fg_on_three_screens(); + } + elsif ($screens == 2) { + fg_on_two_screens(); + } + else { + fg_on_one_screen(); + } + return; +} + +sub main +{ + run_espeak(); + run_terms($ARGV[0]); + return; +} + +main(); + +__END__ |