summaryrefslogtreecommitdiffstats
path: root/.config/bspwm/bspwmrc
diff options
context:
space:
mode:
Diffstat (limited to '.config/bspwm/bspwmrc')
-rwxr-xr-x.config/bspwm/bspwmrc196
1 files changed, 180 insertions, 16 deletions
diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc
index cb7de0d..d64dfe4 100755
--- a/.config/bspwm/bspwmrc
+++ b/.config/bspwm/bspwmrc
@@ -3,6 +3,8 @@
use strict;
use warnings;
use Capture::Tiny qw(capture);
+use Time::HiRes;
+use WWW::Curl::Easy;
use constant {
SXHKD_PATH => '/usr/local/bin/sxhkd',
@@ -21,8 +23,16 @@ use constant {
LOWBAT_PATH => '/usr/local/bin/lowbat',
EMACS_PATH => '/usr/local/bin/emacs',
ALACRITTY_PATH => '/usr/local/bin/alacritty',
- TERMS_THREAD => '/usr/home/jozan/.config/bspwm/terms_thread.pl',
- NETWORK_THREAD => '/usr/home/jozan/.config/bspwm/network_thread.pl'
+ PGREP_PATH => '/bin/pgrep',
+ ESPEAK_PATH => '/usr/local/bin/espeak',
+ 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',
+ GIT_PATH => '/usr/local/bin/git',
+ QTOX_PATH => '/usr/local/bin/qtox'
};
use constant {
BSP_BORDER_WIDTH => 1,
@@ -33,9 +43,11 @@ use constant {
BSP_GAPLESS_MONOCLE => 'true',
BSP_SINGLE_MONOCLE => 'true',
XSET_R_RATE_DELAY => 200,
- XSET_R_RATE_RATE => 100,
+ XSET_R_RATE_RATE => 100
};
-use constant WALLPAPER_PATH => '/usr/home/jozan/Pictures/wallpaper.jpg';
+use constant WALLPAPER_PATH => '/usr/home/jozan/Pictures/wallpaper.jpg';
+use constant COWSAY_WELCOME => 'Welcome back, partner! And remember to try glest!';
+use constant NETWORK_TEST_URL => 'https://www.freebsd.org/';
sub run_if_dead
{
@@ -135,29 +147,181 @@ sub run_bg_programs
return;
}
-sub run_fg_programs
+sub run_espeak
{
- my ($screens) = @_;
- my $pid;
+ 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(3.6);
+ $term_pid[1] = fork();
+ if (not $term_pid[1]) {
+ exec(ALACRITTY_PATH, '-e', HTOP_PATH);
+ exit;
+ }
+ Time::HiRes::sleep(3.6);
+ $term_pid[2] = fork();
+ if (not $term_pid[2]) {
+ exec(ALACRITTY_PATH, '-e', GOTOP_PATH);
+ exit;
+ }
+ Time::HiRes::sleep(3.6);
+ 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(3.6);
+ 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(3.6);
+ $term_pid[1] = fork();
+ if (not $term_pid[1]) {
+ exec(ALACRITTY_PATH, '-e', HTOP_PATH);
+ exit;
+ }
+ Time::HiRes::sleep(3.6);
+ $term_pid[2] = fork();
+ if (not $term_pid[2]) {
+ exec(ALACRITTY_PATH, '-e', GOTOP_PATH);
+ exit;
+ }
+ Time::HiRes::sleep(3.6);
+ 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(3.6);
+ 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;
- $pid = fork();
- if (not $pid) {
- exec(TERMS_THREAD, $screens);
+ $term_pid[0] = fork();
+ if (not $term_pid[0]) {
+ exec(
+ ALACRITTY_PATH, '-e', SH_PATH, '-c',
+ COWSAY_PATH . ' "' . COWSAY_WELCOME . '"; ' . ZSH_PATH
+ );
exit;
}
- sleep(14);
+ Time::HiRes::sleep(3.6);
+ 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(3.6);
+ $term_pid[2] = fork();
+ if (not $term_pid[2]) {
+ exec(ALACRITTY_PATH, '-e', GOTOP_PATH);
+ }
+ Time::HiRes::sleep(3.6);
+ system(BSPC_PATH, 'node', '-f', 'east');
+ $term_pid[3] = fork();
+ if (not $term_pid[3]) {
+ exec(ALACRITTY_PATH, '-e', VIFM_PATH);
+ }
+ Time::HiRes::sleep(3.6);
+ 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();
+ }
+ system(BSPC_PATH, 'desktop', '-f', '01');
+ return;
+}
+
+sub run_fg_programs
+{
+ my ($screens) = @_;
+
+ run_espeak();
+ run_terms($screens);
run_if_dead(EMACS_PATH);
return;
}
sub run_network_programs
{
- my $pid;
+ my $curl;
+ my $response_body;
- $pid = fork();
- if (not $pid) {
- exec(NETWORK_THREAD);
- exit;
+ $curl = WWW::Curl::Easy->new;
+ $curl->setopt(CURLOPT_URL, NETWORK_TEST_URL);
+ $curl->setopt(CURLOPT_WRITEDATA, \$response_body);
+ if ($curl->perform == 0) {
+ system(GIT_PATH, '-C', '/usr/home/jozan/.elfeed', 'pull', 'origin', 'master');
+ run_if_dead(QTOX_PATH);
}
return;
}