diff options
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/backup | 13 | ||||
-rwxr-xr-x | .local/bin/dmapps | 8 | ||||
-rwxr-xr-x | .local/bin/dmbookm | 3 | ||||
-rwxr-xr-x | .local/bin/dmlog | 11 | ||||
-rwxr-xr-x | .local/bin/dmpass | 12 | ||||
-rwxr-xr-x | .local/bin/dmrun | 6 | ||||
-rwxr-xr-x | .local/bin/linkview | 721 | ||||
-rwxr-xr-x | .local/bin/mic | 45 | ||||
-rwxr-xr-x | .local/bin/mixer-set | 86 | ||||
-rwxr-xr-x | .local/bin/nb | 1 | ||||
-rwxr-xr-x | .local/bin/ndate | 5 | ||||
-rwxr-xr-x | .local/bin/newsboat-notif | 3 | ||||
-rwxr-xr-x | .local/bin/ref-newsboat | 24 | ||||
-rwxr-xr-x | .local/bin/scr1 | 16 | ||||
-rwxr-xr-x | .local/bin/scr2 | 21 | ||||
-rwxr-xr-x | .local/bin/scr3 | 13 | ||||
-rwxr-xr-x | .local/bin/scrext | 55 | ||||
-rwxr-xr-x | .local/bin/scrhome | 59 | ||||
-rwxr-xr-x | .local/bin/scrmain | 55 | ||||
-rwxr-xr-x | .local/bin/scrvince | 56 | ||||
-rwxr-xr-x | .local/bin/scrvincetv | 56 | ||||
-rwxr-xr-x | .local/bin/scrwork | 53 | ||||
-rwxr-xr-x | .local/bin/setwp | 42 | ||||
-rwxr-xr-x | .local/bin/synchdd | 4 |
24 files changed, 640 insertions, 728 deletions
diff --git a/.local/bin/backup b/.local/bin/backup new file mode 100755 index 0000000..06b168c --- /dev/null +++ b/.local/bin/backup @@ -0,0 +1,13 @@ +#!/bin/sh + +rsync -avhz --progress --delete-after "${HOME}"/games/ssd/steam/steamapps/common/Morrowind/Saves zhinu:/var/mother_backup/morrowind/ +rsync -avhz --progress --delete-after "${HOME}"/games/ssd/ksp-gpp-2/saves zhinu:/var/mother_backup/ksp_gpp/ +rsync -avhz --progress --delete-after "${HOME}"/games/ssd/ksp-gpp-2/GameData zhinu:/var/mother_backup/ksp_gpp/ +rsync -avhz --progress --delete-after "${HOME}"/games/ssd/ksp-kcalbeloh/saves zhinu:/var/mother_backup/ksp_kcalbeloh/ +rsync -avhz --progress --delete-after "${HOME}"/games/ssd/ksp-kcalbeloh/GameData zhinu:/var/mother_backup/ksp_kcalbeloh/ +rsync -avhz --progress --delete-after "${XDG_DATA_HOME}"/pass zhinu:/var/mother_backup/pass/ +rsync -avhz --progress --delete-after "${XDG_DATA_HOME}"/newsboat/ zhinu:/var/mother_backup/newsboat/data/ +rsync -avhz --progress --delete-after "${XDG_CONFIG_HOME}"/newsboat/ zhinu:/var/mother_backup/newsboat/conf/ +rsync -avhz --progress --delete-after "${HOME}"/dev/c/c_dergods_realm_2 zhinu:/var/mother_backup/dr2/ +rsync -avhz --progress --delete-after "${HOME}"/mid/sort zhinu:/var/mother_backup/ +ssh zhinu -- 'chown -v 1000: /var/mother_backup/*' diff --git a/.local/bin/dmapps b/.local/bin/dmapps index af0c26d..0ce4c81 100755 --- a/.local/bin/dmapps +++ b/.local/bin/dmapps @@ -41,6 +41,7 @@ use constant PROG_LIST => "" . "Liferea" . "\n" . "HexChat" . "\n" . "--- Audio ---" . "\n" . +"Ardour" . "\n" . "REAPER" . "\n" . "Audacity" . "\n" . "Pulse Control Panel" . "\n" . @@ -104,6 +105,7 @@ sub run exec("signal-desktop") if $action =~ "Signal"; exec("liferea") if $action =~ "Liferea"; exec("hexchat") if $action =~ "HexChat"; + exec("ardour8") if $action =~ "Ardour"; exec("reaper") if $action =~ "REAPER"; exec("audacity") if $action =~ "Audacity"; exec("pavucontrol") if $action =~ "Pulse Control Panel"; @@ -146,7 +148,11 @@ sub main if (hostname() eq "po-rbo.ln.ysosecure.com") { $prompt .= WORK_LIST; } - $action = `dmenu -i -l 100 -sb '$color' -shb '$color' <<LIST + my $menu = "dmenu -sb '$color' -shb '$color'"; + if (defined $ENV{WAYLAND_DISPLAY}) { + $menu = "wmenu -S '$color'"; + } + $action = `$menu -i -l 100 <<LIST $prompt LIST`; if (not $action) { diff --git a/.local/bin/dmbookm b/.local/bin/dmbookm index 22a9e52..dcd0e36 100755 --- a/.local/bin/dmbookm +++ b/.local/bin/dmbookm @@ -37,6 +37,9 @@ use constant LIST => { nua_aether => 'https://aether.int.ysosecure.com/ui', nua_gaia => 'https://gaia.int.ysosecure.com/', nua_certsrv => 'https://orca1.int.ysosecure.com/certsrv', + nua_sentry => 'https://sentry.nuabee.fr/', + nua_leek => 'https://leek.int.ysosecure.com/', + nua_otc => 'https://auth.otc.t-systems.com/', }; sub main diff --git a/.local/bin/dmlog b/.local/bin/dmlog index d209ee5..600e4d4 100755 --- a/.local/bin/dmlog +++ b/.local/bin/dmlog @@ -64,7 +64,8 @@ sub action "-fail-color", "0xcc241d"); } else { - exec(XSCREENSAVER_PATH, '-lock'); + exec(SLOCK_PATH); + # exec(XSCREENSAVER_PATH, '-lock'); } } elsif ($var eq ${+LIST}[1]) { @@ -90,10 +91,11 @@ sub action ); sleep 2; if (HOSTNAME eq 'mother') { + system('umount', '-f', '/var/dev/ceres'); exec(LOGINCTL_PATH, 'suspend'); } elsif (HOSTNAME eq 'po-rbo') { - exec('systemctl', 'suspend'); + exec('doas', 'systemctl', 'suspend'); } exec(ACPI_PATH, '-s', '3'); } @@ -109,10 +111,11 @@ sub action elsif ($var eq ${+LIST}[3]) { if (confirm($var, $color) == 1) { if (HOSTNAME eq 'mother') { + system('umount', '-f', '/var/dev/ceres'); exec(LOGINCTL_PATH, 'reboot'); } elsif (HOSTNAME eq 'po-rbo') { - exec('systemctl', 'reboot'); + exec('doas', 'systemctl', 'reboot'); } system( NOTIF_PATH, @@ -138,7 +141,7 @@ sub action exec(LOGINCTL_PATH, 'poweroff'); } elsif (HOSTNAME eq 'po-rbo') { - exec('systemctl', 'poweroff'); + exec('doas', 'systemctl', 'poweroff'); } exec(SHUTDOWN_PATH, '-p', 'now'); } diff --git a/.local/bin/dmpass b/.local/bin/dmpass index affe65b..475b96e 100755 --- a/.local/bin/dmpass +++ b/.local/bin/dmpass @@ -35,9 +35,17 @@ p="$(pass show "$password")" if [ $full -eq 1 ]; then id=$(printf "%s" "$password" | sed 's/.*___//') printf "%s\n" $id | { IFS= read -r pass; printf %s "$id"; } | $xdotool - xdotool key Tab + if [ -n "$WAYLAND_DISPLAY" ]; then + ydotool key 15:1 15:0 + else + xdotool key Tab + fi printf "%s\n" "$p" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool - xdotool key Return + if [ -n "$WAYLAND_DISPLAY" ]; then + ydotool key 28:1 28:0 + else + xdotool key Return + fi exit fi diff --git a/.local/bin/dmrun b/.local/bin/dmrun index f47c232..41c0e0e 100755 --- a/.local/bin/dmrun +++ b/.local/bin/dmrun @@ -11,7 +11,11 @@ sub main if (@ARGV == 1) { $color = $ARGV[0]; } - return exec("dmenu_run -i -sb '$color' -shb '$color'"); + my $menu = "dmenu_run -sb '$color' -shb '$color'"; + if (defined $ENV{WAYLAND_DISPLAY}) { + $menu = "wmenu-run -S '$color'"; + } + return exec("$menu -i"); } main(); diff --git a/.local/bin/linkview b/.local/bin/linkview index ec928a4..68d5bcb 100755 --- a/.local/bin/linkview +++ b/.local/bin/linkview @@ -5,27 +5,20 @@ use warnings; use Sys::Hostname; use Scalar::Util qw(looks_like_number); use File::HomeDir qw(home); -use File::Basename qw(basename); +use File::Basename qw(basename fileparse); use Cwd qw(cwd); use Env qw(BROWSER TERMINAL); -use Term::ReadKey; use Capture::Tiny qw(capture); use POSIX qw(setsid); -use feature qw(switch); -no warnings qw(experimental::smartmatch); +use Data::UUID; -my $menu = "dmenu"; -my $IMGVIEW_PATH = 'nsxiv -b -a'; - -if (defined $ENV{WAYLAND_DISPLAY}) { - $menu = "wmenu"; - $IMGVIEW_PATH = 'imv'; -} +my $menu = "fzf"; use constant { TERMINAL_PATH => $TERMINAL, MPV_PATH => 'mpv', YTDL_PATH => 'yt-dlp', + IMGVIEW_PATH => 'nsxiv -b -a', FETCH_PATH => 'fetch', CURL_PATH => 'curl', ZATHURA_PATH => 'zathura', @@ -33,32 +26,139 @@ use constant { BROWSER_PATH => $BROWSER, NOTIFYSEND_PATH => 'notify-send', COPYQ_PATH => 'copyq', - HOSTNAME => (split /\./, hostname()) + HOSTNAME => (split /\./, hostname())[0] }; -use constant PROG_LIST => "" . -"mpv" . "\n" . -"mpv-term" . "\n" . -"ytdl" . "\n" . -"ytdl thumbnail" . "\n" . -"fetch" . "\n" . -"img" . "\n" . -"zathura" . "\n" . -"w3m" . "\n" . -"browser" . "\n" . -"clip" . "\n"; + +my @keys = ( 'vid', 'img', 'dl', 'audio', 'pdf', 'w3m', 'web', 'clip' ); +my @func_refs = ( \&vid, \&img_pdf, \&dl, \&audio, \&img_pdf, \&w3m, \&web, \&clip ); +my %func_list; +@func_list{@keys} = @func_refs; + use constant QUAL_LIST => "" . -"1440" . "\n" . -"1080" . "\n" . -"720" . "\n" . -"480" . "\n" . -"360" . "\n" . -"240" . "\n" . -"144" . "\n" . -"uncap" . "\n"; +"uncap" . "\n" . +"1440" . "\n" . +"1080" . "\n" . +"720" . "\n" . +"480" . "\n" . +"360" . "\n" . +"240" . "\n" . +"144" . "\n"; + +sub vid +{ + my ($url, $article_name) = @_; + my $pid; + + $article_name = "some media" unless defined $article_name; + $pid = fork(); + if (not $pid) { + setsid(); + close_io(); + system( + NOTIFYSEND_PATH, + '-t', '2000', + 'playing media', + ' playing <b>' . $article_name . '</b>' + ); + if (system(MPV_PATH, "--force-window=yes", $url) != 0) { + exec( + NOTIFYSEND_PATH, + '-u', 'critical', + '-t', '10000', + 'playback failed', + ' failed to open <b>' . $url . '</b>' + ); + } + return; + } + return; +} -sub open_link +sub img_pdf { - my ($a, $url) = @_; + my ($url, $article_name, $key) = @_; + my $file_name; + my $new_file_name; + my $pid; + my $ret; + my $tmp; + my $ug; + my $uuid; + + $article_name = "some media" if ($article_name eq ""); + $pid = fork(); + if (not $pid) { + setsid(); + close_io(); + chdir '/tmp' or die $!; + $file_name = $url; + $file_name =~ s/.+\///g; + if (is_yt($url) != 0) { + system( + NOTIFYSEND_PATH, + '-t', '5000', + 'fetching thumbnail', + ' fetching thumbnail for <b>' . $article_name . '</b>' + ); + ($tmp, undef, $ret) = capture { + system(YTDL_PATH, '--get-thumbnail', $url); + }; + chomp $tmp; + if ($ret != 0) { + system( + NOTIFYSEND_PATH, + '-u', 'critical', + 'failed to get thumbnail', + ' failed to get thumbail for <b>' . $article_name . '</b>' + ); + return; + } + $url = $tmp; + } + else { + system( + NOTIFYSEND_PATH, + '-t', '5000', + 'download started', + ' fetching <b>'. $file_name . '</b> to <b>/tmp</b>' + ); + } + $file_name = $url; + $file_name =~ s/.+\///g; + if (HOSTNAME eq "mother" or "po-rbo") { + system(CURL_PATH, "-fsSLO", $url); + } elsif (HOSTNAME == "mars") { + system(FETCH_PATH, "-q", $url); + } + my ($name, undef, $ext) = fileparse($file_name, qr/\.[^.]*/); + $ug = Data::UUID->new; + $uuid = $ug->create_str(); + $ext =~ s/\?.*//; + $new_file_name = $uuid . $ext; + rename($file_name, $new_file_name) or die $!; + if ($key =~ /img/) { + $ret = system(IMGVIEW_PATH . " " . $new_file_name); + } + else { + $ret = system(ZATHURA_PATH, $new_file_name); + } + if ($ret != 0) { + system( + NOTIFYSEND_PATH, + '-u', 'critical', + 'failed to open image', + ' failed to open file <b>/tmp/'. $new_file_name . '</b>' + ); + } + unlink($new_file_name); + return; + } + return; +} + +sub dl +{ + my ($url) = @_; my $count; my $file_name; my $i; @@ -68,196 +168,83 @@ sub open_link my $pwd; my $quality; my $ret; - my $tmp; my $tmpfile; my $val; my @wc; - if ($a eq "mpv") { - if (system(MPV_PATH, $url) != 0) { - system( - NOTIFYSEND_PATH, - '-u', 'critical', - '-t', '10000', - 'playback failed', - ' Failed to open <b>' . $url . '</b>' - ); + if (is_yt($url) != 0) { + $list = QUAL_LIST; + $quality = `printf "$list" | $menu --prompt 'quality > '`; + if (not $quality) { + return; } - exit 0; + chomp $quality; } - elsif ($a eq "mpv-term") { - exec(TERMINAL_PATH, '-e', MPV_PATH, '--audio-channels=stereo', $url); - } - elsif ($a eq "fetch" || $a eq "ytdl") { - $pid = fork(); - if (not $pid) { - setsid(); - $ret = -1; - if ($a eq "ytdl") { - $list = QUAL_LIST; - $quality = `printf "$list" | $menu -l 8`; - if (not $quality) { - exit 0; - } - chomp $quality; - chdir home() . "/dl" or - chdir home() . "/Downloads" or - chdir home() or die $!; - if (basename(cwd()) eq basename(home())) { - $pwd = '~/'; - } - else { - $pwd = '~/' . basename(cwd()); - } - $file_name = $url; - $file_name =~ s/.+\///g; - $file_name = `yt-dlp -e $url`; - if (not $file_name) { - $file_name = "YouTube video"; - } - chomp $file_name; - @wc = split / /, $file_name; - if (@wc > 8) { - $file_name = ""; - $i = 0; - while ($i < 8) { - $file_name .= "$wc[$i] "; - $i++; - } - $file_name .= "[...]"; - } - $file_name =~ s/^[0-9]+/\[\.\.\.\]/; - system( - NOTIFYSEND_PATH, - '-u', 'low', - '-t', '2000', - 'download started', - ' <b>' . $file_name . '</b> started downloading' - ); - $tmpfile = `mktemp`; - chomp $tmpfile; - $pid2 = fork(); - if (not $pid2) { - (undef, undef, $ret) = capture { - if ($quality eq 'uncap') { - system(YTDL_PATH . ' --newline --add-metadata ' . $url . ' >' . $tmpfile); - } - elsif ($quality eq '1440') { - system(YTDL_PATH . " -f '308+140' --newline --add-metadata " . $url . ' >' . $tmpfile); - } - elsif ($quality eq '1080') { - system(YTDL_PATH . " -f '299+140' --newline --add-metadata " . $url . ' >' . $tmpfile); - } - elsif ($quality eq '720') { - system(YTDL_PATH . " -f '298+140' --newline --add-metadata " . $url . ' >' . $tmpfile); - } - else { - system(YTDL_PATH . " -f '[height<=" . $quality . "]' --newline --add-metadata " . $url . ' >' . $tmpfile); - } - }; - if ($ret == 0) { - system( - NOTIFYSEND_PATH, - '-u', 'normal', - '-t', '10000', - 'download complete', - ' <b>' . $file_name . '</b> downloaded successfully to ' . - '<b>' . $pwd . '</b>' - ); + $pid = fork(); + if (not $pid) { + setsid(); + close_io(); + $ret = -1; + chdir home() . "/dl" or + chdir home() . "/Downloads" or + chdir home() or die $!; + if (basename(cwd()) eq basename(home())) { + $pwd = '~/'; + } + else { + $pwd = '~/' . basename(cwd()); + } + if (is_yt($url) != 0) { + $file_name = get_yt_vid_name($url); + } + else { + $file_name = $url; + $file_name =~ s/.+\///g; + } + chomp $file_name; + @wc = split / /, $file_name; + if (@wc > 8) { + $file_name = ""; + $i = 0; + while ($i < 8) { + $file_name .= "$wc[$i] "; + $i++; + } + $file_name .= "[...]"; + } + $file_name =~ s/^[0-9]+/\[\.\.\.\]/; + system( + NOTIFYSEND_PATH, + '-t', '2000', + 'download starting', + ' downloading <b>' . $file_name . '</b>' + ); + if (is_yt($url) != 0) { + $tmpfile = `mktemp`; + chomp $tmpfile; + $pid2 = fork(); + if (not $pid2) { + (undef, undef, $ret) = capture { + if ($quality eq 'uncap') { + system(YTDL_PATH . ' --newline --add-metadata ' . $url . ' >' . $tmpfile); } - else { - system( - NOTIFYSEND_PATH, - '-u', 'critical', - '-t', '10000', - 'download failed', - ' failed to download <b>' . $file_name . '</b>' - ); + elsif ($quality eq '1440') { + system(YTDL_PATH . " -f '308+140' --newline --add-metadata " . $url . ' >' . $tmpfile); } - exit 0; - } - elsif ($pid2 < 0) { - system( - NOTIFYSEND_PATH, - '-u', 'critical', - '-t', '10000', - 'download failed', - ' failed to <b>fork(2)</b>' - ); - exit 0; - } - else { - $count = 0; - while (1) { - $val = `tail -n 1 "$tmpfile" | awk '{print \$2}' | tr -d '%'`; - if (looks_like_number($val) != 0) { - system( - NOTIFYSEND_PATH, - '-h', - 'int:value:' . $val, - '-u', 'low', - '-t', '5000', - 'downloading', - ' downloading <b>' . $file_name . '</b>' - ); - if ($val == 100 || system('pgrep python >/dev/null 2>&1') != 0) { - last; - } - } - else { - if ($count == 10) { - last; - } - $count += 1; - } - sleep 2; + elsif ($quality eq '1080') { + system(YTDL_PATH . " -f '299+140' --newline --add-metadata " . $url . ' >' . $tmpfile); } - unlink $tmpfile; - } - exit 0; - } - else { - chdir home() . "/dl" or - chdir home() . "/Downloads" or - chdir home() or die $!; - if (basename(cwd()) eq basename(home())) { - $pwd = '~/'; - } - else { - $pwd = '~/' . basename(cwd()); - } - $file_name = $url; - $file_name =~ s/.+\///g; - @wc = split / /, $file_name; - if (@wc > 8) { - $file_name = ""; - $i = 0; - while ($i < 8) { - $file_name .= "$wc[$i] "; - $i++; + elsif ($quality eq '720') { + system(YTDL_PATH . " -f '298+140' --newline --add-metadata " . $url . ' >' . $tmpfile); } - $file_name .= "[...]"; - } - $file_name =~ s/^[0-9]+/\[\.\.\.\]/; - system( - NOTIFYSEND_PATH, - '-u', 'low', - '-t', '10000', - 'download started', - ' <b>' . $file_name . '</b> started downloading' - ); - (undef, undef, $ret) = capture { - if (HOSTNAME eq "mother" or "po-rbo") { - system(CURL_PATH, "-fsSLO", $url); - } elsif (HOSTNAME == "mars") { - system(FETCH_PATH, $url); + else { + system(YTDL_PATH . " -f '[height<=" . $quality . "]' --newline --add-metadata " . $url . ' >' . $tmpfile); } }; if ($ret == 0) { system( NOTIFYSEND_PATH, '-u', 'normal', - '-t', '10000', 'download complete', ' <b>' . $file_name . '</b> downloaded successfully to ' . '<b>' . $pwd . '</b>' @@ -267,159 +254,261 @@ sub open_link system( NOTIFYSEND_PATH, '-u', 'critical', - '-t', '10000', 'download failed', ' failed to download <b>' . $file_name . '</b>' ); } + return; } - exit 0; - } - elsif ($pid < 0) { - system( - NOTIFYSEND_PATH, - '-u', 'critical', - '-t', '10000', - 'download failed', - ' failed to <b>fork(2)</b>' - ); - exit 0; - } - else { - exit 0; - } - } - elsif ($a eq "ytdl thumbnail") { - $pid = fork(); - if (not $pid) { - setsid(); - chdir '/tmp' or die $!; - $file_name = $url; - $file_name =~ s/.+\///g; - if ($file_name =~ m/^watch\?v=.+/) { - $file_name = `yt-dlp -e $url`; - if (not $file_name) { - $file_name = "Youtube video"; - } - chomp $file_name; - } - system( - NOTIFYSEND_PATH, - '-u', 'low', - '-t', '5000', - 'download started', - ' fetching thumbnail for <b>'. $file_name . '</b>' - ); - ($tmp, undef, $ret) = capture { - system(YTDL_PATH, '--get-thumbnail', $url); - }; - chomp $tmp; - if ($ret != 0) { + elsif ($pid2 < 0) { system( NOTIFYSEND_PATH, '-u', 'critical', - '-t', '10000', - 'failed to get thumbnail', - ' failed to get thumbail for <b>'. $file_name . '</b>' + 'download failed', + ' failed to <b>fork(2)</b>' ); - exit 0; + return; } - given (HOSTNAME) { - when(["mother", "po-rbo"]) { - system(CURL_PATH, "-fsSLO", $tmp); - } - when("mars") { - system(FETCH_PATH, '-q', $tmp); + else { + $count = 0; + while (1) { + $val = `tail -n 1 "$tmpfile" | awk '{print \$2}' | tr -d '%'`; + if (looks_like_number($val) != 0) { + system( + NOTIFYSEND_PATH, + '-h', + 'int:value:' . $val, + '-u', 'low', + '-t', '5000', + 'downloading', + ' downloading <b>' . $file_name . '</b>' + ); + if ($val == 100 || system('pgrep yt-dlp >/dev/null 2>&1') != 0) { + last; + } + } + else { + if ($count == 10) { + last; + } + $count += 1; + } + sleep 2; } + unlink $tmpfile; } - $file_name = $tmp; - $file_name =~ s/.+\///g; - chomp $file_name; - system("magick", $file_name, $file_name . ".jpg"); - system($IMGVIEW_PATH . " " . $file_name . ".jpg"); - unlink($file_name); - unlink($file_name . ".jpg"); - exit 0; + return; } - } - elsif ($a eq "img" || $a eq "zathura") { - $pid = fork(); - if (not $pid) { - setsid(); - chdir '/tmp' or die $!; - $file_name = $url; - $file_name =~ s/.+\///g; - system( - NOTIFYSEND_PATH, - '-u', 'low', - '-t', '5000', - 'download started', - ' fetching <b>'. $file_name . '</b> to <b>/tmp</b>' - ); - given (HOSTNAME) { - when(["mother", "po-rbo"]) { + else { + (undef, undef, $ret) = capture { + if (HOSTNAME eq "mother" or "po-rbo") { system(CURL_PATH, "-fsSLO", $url); + } elsif (HOSTNAME == "mars") { + system(FETCH_PATH, "-q", $url); } - when("mars") { - system(FETCH_PATH, '-q', $url); - } - } - if ($a eq "img") { - exec($IMGVIEW_PATH . " " . $file_name); + }; + if ($ret == 0) { + system( + NOTIFYSEND_PATH, + '-u', 'normal', + 'download complete', + ' <b>' . $file_name . '</b> downloaded successfully to ' . + '<b>' . $pwd . '</b>' + ); } else { - exec(ZATHURA_PATH, $file_name); + system( + NOTIFYSEND_PATH, + '-u', 'critical', + 'download failed', + ' failed to download <b>' . $file_name . '</b>' + ); } } + return; } - elsif ($a eq "w3m") { - exec(TERMINAL_PATH, '-e', W3M_PATH, $url); + elsif ($pid < 0) { + system( + NOTIFYSEND_PATH, + '-u', 'critical', + '-t', '10000', + 'download failed', + ' failed to <b>fork(2)</b>' + ); + return; } - elsif ($a eq "browser") { - $pid = fork(); - if (not $pid) { - setsid(); - capture { - exec(BROWSER_PATH, $url); - }; + return; +} + +sub audio +{ + my ($url, $article_name) = @_; + my $pid; + + $pid = fork(); + if (not $pid) { + setsid(); + close_io(); + system( + NOTIFYSEND_PATH, + '-t', '2000', + 'playing media', + ' playing <b>' . $article_name . '</b>' + ); + if (system( + TERMINAL_PATH, + "-e", + MPV_PATH, + "--vo=null", + "--video=no", + "--no-video", + $url + ) != 0) { + exec( + NOTIFYSEND_PATH, + '-u', 'critical', + '-t', '10000', + 'playback failed', + ' failed to open <b>' . $url . '</b>' + ); } + return; } - elsif ($a eq "clip") { - $pid = fork(); - if (not $pid) { - setsid(); - capture { - exec(COPYQ_PATH, "copy", $url); - }; + return; +} + +sub w3m +{ + my ($url) = @_; + my $pid; + + $pid = fork(); + if (not $pid) { + setsid(); + close_io(); + if (system(TERMINAL_PATH, '-e', W3M_PATH, $url) != 0) { + exec( + NOTIFYSEND_PATH, + '-u', 'critical', + '-t', '10000', + 'w3m failed', + ' failed to open <b>' . $url . '</b>' + ); + } + return; + } + return; +} + +sub web +{ + my ($url) = @_; + my $pid; + + $pid = fork(); + if (not $pid) { + setsid(); + close_io(); + exec(BROWSER_PATH, $url); + } + return; +} + +sub clip +{ + my ($url) = @_; + my $pid; + + $pid = fork(); + if (not $pid) { + setsid(); + close_io(); + if (defined $ENV{WAYLAND_DISPLAY}) { + system("echo -n " . $url . " | wl-copy"); + return; + } + else { + exec(COPYQ_PATH, "copy", $url); } } + system( + NOTIFYSEND_PATH, + '-t', '2000', + 'clipped url', + ' clipped url' + ); + return; +} + +sub close_io +{ + open STDIN, '<', '/dev/null' or die $!; + open STDOUT, '>', '/dev/null' or die $!; + open STDERR, '>', '/dev/null' or die $!; return; } -sub dmenu_prompt +sub is_yt +{ + my ($url) = @_; + + return $url =~ m{ + ^(?:https?://)? + (?:www\.|m\.)? + (?:youtube\.com|youtu\.be)/ + (?: + (?:watch\?v=|embed/|v/|shorts/)? + ) + ([\w-]{11}) + }x; +} + +sub get_yt_vid_name +{ + my ($url) = @_; + my $file_name; + + system( + NOTIFYSEND_PATH, + '-t', '4000', + 'checking name', + ' looking for video name' + ); + $file_name = `yt-dlp -e $url`; + if (not $file_name) { + $file_name = "yt video"; + } + chomp $file_name; + return $file_name; +} + +sub fzf_prompt { my ($url) = @_; my $answer; - my $list = PROG_LIST; + my $list; - $answer = `printf "$list\nURL: $url\n" | $menu -i`; + $list = join("\n", @keys); + $answer = `printf "$list\n" | $menu --prompt '$url > '`; chomp $answer; return $answer; } -sub main +sub linkview { my $answer; - if (@ARGV == 0) { + if (@ARGV == 0 || $ARGV[0] eq '') { print STDERR "linkview: no URL\n"; exit 1; } - $answer = dmenu_prompt($ARGV[0]); - open_link($answer, $ARGV[0]); + + $answer = fzf_prompt($ARGV[0]); + return unless exists $func_list{$answer}; + $func_list{$answer}->($ARGV[0], $ARGV[1], $answer); return; } -main(); +linkview(); __END__ diff --git a/.local/bin/mic b/.local/bin/mic index b53c966..492c773 100755 --- a/.local/bin/mic +++ b/.local/bin/mic @@ -3,6 +3,7 @@ use strict; use warnings; use Capture::Tiny qw(capture); +use Sys::Hostname qw(hostname); use constant { MIXER_PATH => '/usr/sbin/mixer', @@ -12,22 +13,52 @@ use constant { sub main { my $rec_vol; + my $host; - $rec_vol = `mixer rec | awk -F ':' '{print \$2}'`; - chomp $rec_vol; - if ($rec_vol == 0) { - capture { - system(MIXER_PATH, 'rec', '100'); + $host = hostname(); + if ($host eq "po-rbo.ln.ysosecure.com") { + system('/usr/bin/pactl', 'set-source-mute', '@DEFAULT_SOURCE@', 'toggle'); + my $muted = `/usr/bin/pactl get-source-mute \@DEFAULT_SOURCE\@ | awk '{print \$2}'`; + chomp $muted; + if ($muted eq "yes") { system( - NOTIF_PATH, + '/usr/bin/notify-send', '-u', 'low', '-t', '1750', 'mixer-set', - ' Microphone restored' + ' muted' ); + } + else { + system( + '/usr/bin/notify-send', + '-u', + 'low', + '-t', + '1750', + 'mixer-set', + ' restored' + ); + } + exit; + } + $rec_vol = `mixer rec | awk -F ':' '{print \$2}'`; + chomp $rec_vol; + if ($rec_vol == 0) { + capture { + system(MIXER_PATH, 'rec', '100'); }; + system( + NOTIF_PATH, + '-u', + 'low', + '-t', + '1750', + 'mixer-set', + ' Microphone restored' + ); } else { capture { diff --git a/.local/bin/mixer-set b/.local/bin/mixer-set index c5911bb..9963c91 100755 --- a/.local/bin/mixer-set +++ b/.local/bin/mixer-set @@ -4,6 +4,7 @@ use strict; use warnings; use Term::ANSIColor; use Capture::Tiny qw(capture); +use Sys::Hostname qw(hostname); sub main { my $argc = $#ARGV + 1; @@ -21,23 +22,41 @@ sub main { print "Too many arguments, only one needed\n"; exit 2; } + my $host = hostname(); my $curr_vol = 0; my $curr_vol_cmd = "/usr/sbin/mixer vol | /usr/bin/awk -F ':' '{print \$2}'"; + if ($host eq "po-rbo.ln.ysosecure.com") { + $curr_vol_cmd = "/usr/bin/pactl get-sink-volume \@DEFAULT_SINK\@ | /usr/bin/awk '{print \$5}'"; + } + my $ns = '/usr/local/bin/notify-send'; + if (hostname() eq "po-rbo.ln.ysosecure.com") { + $ns = '/usr/bin/notify-send'; + } if ($ARGV[0] eq "lower" || $ARGV[0] eq "raise") { if ($ARGV[0] eq "lower") { - capture { - system('/usr/sbin/mixer', 'vol', '-5'); - }; + if ($host eq "po-rbo.ln.ysosecure.com") { + system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', '-5%'); + } + else { + capture { + system('/usr/sbin/mixer', 'vol', '-5'); + }; + } } else { - capture { - system('/usr/sbin/mixer', 'vol', '+5'); - }; + if ($host eq "po-rbo.ln.ysosecure.com") { + system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', '+5%'); + } + else { + capture { + system('/usr/sbin/mixer', 'vol', '+5'); + }; + } } $curr_vol = `$curr_vol_cmd`; chomp $curr_vol; system( - '/usr/local/bin/notify-send', + $ns, '-h', 'int:value:' . $curr_vol, '-u', @@ -45,7 +64,7 @@ sub main { '-t', '1000', 'mixer-set', - '墳 Volume' + ' volume' ); system('kill -68 $(pidof dwmblocks)'); exit; @@ -58,21 +77,26 @@ sub main { open(my $fh, '>:encoding(UTF-8)', $tmp_file); print $fh $curr_vol; close($fh); - capture { - system( - '/usr/sbin/mixer', - 'vol', - '0' - ); - }; + if ($host eq "po-rbo.ln.ysosecure.com") { + system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', '0%'); + } + else { + capture { + system( + '/usr/sbin/mixer', + 'vol', + '0' + ); + }; + } system( - '/usr/local/bin/notify-send', + $ns, '-u', 'low', '-t', '1750', 'mixer-set', - '婢 Volume muted' + ' muted' ); system('kill -68 $(pidof dwmblocks)'); } @@ -80,25 +104,21 @@ sub main { open(my $fh, '<:encoding(UTF-8)', $tmp_file); $curr_vol = <$fh>; close($fh); - capture { - system( - '/usr/sbin/mixer', - 'vol', - $curr_vol - ); - }; - my $icon; - if ($curr_vol <= 33) { - $icon = '奄 '; - } - elsif ($curr_vol <= 66) { - $icon = '奔 '; + if ($host eq "po-rbo.ln.ysosecure.com") { + chomp $curr_vol; + system('/usr/bin/pactl', 'set-sink-volume', '@DEFAULT_SINK@', $curr_vol); } else { - $icon = '墳 '; + capture { + system( + '/usr/sbin/mixer', + 'vol', + $curr_vol + ); + }; } system( - '/usr/local/bin/notify-send', + $ns, '-h', 'int:value:' . $curr_vol, '-u', @@ -106,7 +126,7 @@ sub main { '-t', '1750', 'mixer-set', - $icon . ' Volume restored' + ' restored' ); system('kill -68 $(pidof dwmblocks)'); } diff --git a/.local/bin/nb b/.local/bin/nb index 117840d..3b36835 100755 --- a/.local/bin/nb +++ b/.local/bin/nb @@ -1,5 +1,6 @@ #!/bin/sh +[ $(hostname -s) = "po-rbo" ] && exec newsboat [ -f /tmp/cache.db ] && exec newsboat -c /tmp/cache.db -u /tmp/urls cache_file="$XDG_DATA_HOME/newsboat/cache.db.gpg" urls_file="$XDG_CONFIG_HOME/newsboat/urls.gpg" diff --git a/.local/bin/ndate b/.local/bin/ndate index 7986ae7..323be43 100755 --- a/.local/bin/ndate +++ b/.local/bin/ndate @@ -69,10 +69,7 @@ sub main $date = scalar reverse $date; system( NOTIFYSEND_PATH, - '-u', - 'low', - '-t', - '2000', + '-t', '4000', 'date', $date ); diff --git a/.local/bin/newsboat-notif b/.local/bin/newsboat-notif new file mode 100755 index 0000000..cc2b385 --- /dev/null +++ b/.local/bin/newsboat-notif @@ -0,0 +1,3 @@ +#!/bin/sh + +[ $1 -gt 0 ] && notify-send -u normal -t 6000 newsboat " <b>$@</b> new articles" diff --git a/.local/bin/ref-newsboat b/.local/bin/ref-newsboat index 090ca63..ca1aee1 100755 --- a/.local/bin/ref-newsboat +++ b/.local/bin/ref-newsboat @@ -5,27 +5,25 @@ use warnings; use Capture::Tiny qw(capture); use constant { - NEWSBOAT_PATH => '/usr/local/bin/newsboat', - NOTIFY_SEND_PATH => '/usr/local/bin/notify-send' + NEWSBOAT_PATH => 'newsboat', + NOTIFY_SEND_PATH => 'notify-send' }; sub main { my $stdout; + my $nb; + + $nb = NEWSBOAT_PATH; if (system( - NEWSBOAT_PATH, + $nb, '-x', 'reload' ) != 0) { exit 1; } - ($stdout, undef, undef) = capture { - system( - NEWSBOAT_PATH, - '-x', - 'print-unread' - ); - }; + + $stdout = qx($nb -x print-unread); $stdout =~ s/\s.+//; chomp $stdout; if ($stdout != 0) { @@ -33,11 +31,13 @@ sub main NOTIFY_SEND_PATH, '-u', 'low', + '-t', + '4000', 'newsboat', - ' ' . $stdout . ' new articles' + ' <b>' . $stdout . '</b> new articles' ); } - exit 0; + return; } main(); diff --git a/.local/bin/scr1 b/.local/bin/scr1 new file mode 100755 index 0000000..8a14124 --- /dev/null +++ b/.local/bin/scr1 @@ -0,0 +1,16 @@ +#!/bin/sh + +# randr=$(xrandr --query | grep -A 1 DP-4) +# if ! printf "%s" "${randr}" | grep 2560x1440+0+0 >/dev/null 2>&1; +# then +# # ! printf "%s" "${randr}" | grep '144.00\*'; +# fi +xrandr --output DP-4 --mode 2560x1440 --rate 144 --pos 0x0 --rotate normal --primary +xrandr --output HDMI-0 --off +xrandr --output DP-0 --off +xrandr --output DP-1 --off +xrandr --output DP-2 --off +xrandr --output DP-3 --off +xrandr --output DP-5 --off + +setwp "$HOME"/pics/wp.png diff --git a/.local/bin/scr2 b/.local/bin/scr2 new file mode 100755 index 0000000..0f98a7b --- /dev/null +++ b/.local/bin/scr2 @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ "$1" = "low" ]; then + xrandr --output DP-4 --mode 1920x1080 --rate 144 --pos 0x0 --rotate normal --primary + xrandr --output DP-2 --mode 1920x1080 --rate 144 --pos 1920x0 --rotate normal + xrandr --output HDMI-0 --off + xrandr --output DP-0 --off + xrandr --output DP-1 --off + xrandr --output DP-3 --off + xrandr --output DP-5 --off +else + xrandr --output DP-4 --mode 2560x1440 --rate 144 --pos 0x0 --rotate normal --primary + xrandr --output DP-2 --mode 2560x1440 --rate 144 --pos 2560x0 --rotate normal + xrandr --output HDMI-0 --off + xrandr --output DP-0 --off + xrandr --output DP-1 --off + xrandr --output DP-3 --off + xrandr --output DP-5 --off +fi + +setwp "$HOME"/pics/wp.png diff --git a/.local/bin/scr3 b/.local/bin/scr3 new file mode 100755 index 0000000..81b7f86 --- /dev/null +++ b/.local/bin/scr3 @@ -0,0 +1,13 @@ +#!/bin/sh + +xrandr \ + --output HDMI-0 --mode 1920x1080 --rate 50 --pos 0x0 --rotate normal \ + --output DP-0 --off \ + --output DP-1 --off \ + --output DP-2 --mode 2560x1440 --rate 60 --pos 4480x0 --rotate normal \ + --output DP-3 --off \ + --output DP-4 --primary --mode 2560x1440 --rate 144 --pos 1920x0 --rotate normal \ + --output DP-5 --off + + +setwp "$HOME"/pics/wp.png diff --git a/.local/bin/scrext b/.local/bin/scrext deleted file mode 100755 index a8aefbb..0000000 --- a/.local/bin/scrext +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# ======================== -# ===== =============== -# ====== ================ -# ====== ================ -# ====== ==== ==== == -# ====== === == = = -# ====== === = == = -# = === === = == ==== -# = === === = == = = -# == ===== ==== == -# ======================== -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright (c) 2022 Joe -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the organization nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY JOE ''AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL JOE BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# scrext -# Tue Apr 12 16:58:16 CEST 2022 -# Joe -# -# Screen setup when I only want ext HDMI - -xrandr --output LVDS-1 --off -xrandr --output VGA-1 --off -xrandr --output HDMI-1 --mode 1920x1080 --pos 0x0 --rotate normal -xrandr --output DP-1 --off -xrandr --output HDMI-2 --off -xrandr --output HDMI-3 --off -xrandr --output DP-2 --off -xrandr --output DP-3 --off -setwp diff --git a/.local/bin/scrhome b/.local/bin/scrhome deleted file mode 100755 index b234031..0000000 --- a/.local/bin/scrhome +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# ======================== -# ===== =============== -# ====== ================ -# ====== ================ -# ====== ==== ==== == -# ====== === == = = -# ====== === = == = -# = === === = == ==== -# = === === = == = = -# == ===== ==== == -# ======================== -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright (c) 2022 Joe -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the organization nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY JOE ''AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL JOE BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# scrhome -# Sun Apr 17 02:07:55 CEST 2022 -# Joe -# -# Screen setup when I'm at home - -#xrandr \ -# --output LVDS-1 --off \ -# --output VGA-1 --off \ -# --output HDMI-1 --off \ -# --output DP-1 --off \ -# --output DP-2 --off \ -# --output DP-3 --off \ -# --output HDMI-2 --off \ -# --output HDMI-3 --off -xrandr \ - --output HDMI-2 --primary --mode 1920x1080 --pos 1366x0 --rotate normal -setwp -ekb diff --git a/.local/bin/scrmain b/.local/bin/scrmain deleted file mode 100755 index 9ed283f..0000000 --- a/.local/bin/scrmain +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# ======================== -# ===== =============== -# ====== ================ -# ====== ================ -# ====== ==== ==== == -# ====== === == = = -# ====== === = == = -# = === === = == ==== -# = === === = == = = -# == ===== ==== == -# ======================== -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright (c) 2022 Joe -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the organization nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY JOE ''AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL JOE BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# scrwork -# Mon Apr 11 20:02:58 CEST 2022 -# Joe -# -# Screen setup when I only want my laptop screen - -xrandr --output LVDS-1 --primary --mode 1366x768 --pos 0x0 --rotate normal \ - --output VGA-1 --off \ - --output HDMI-1 --off \ - --output DP-1 --off \ - --output HDMI-2 --off \ - --output HDMI-3 --off \ - --output DP-2 --off \ - --output DP-3 --off -setwp diff --git a/.local/bin/scrvince b/.local/bin/scrvince deleted file mode 100755 index eeed01e..0000000 --- a/.local/bin/scrvince +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# ======================== -# ===== =============== -# ====== ================ -# ====== ================ -# ====== ==== ==== == -# ====== === == = = -# ====== === = == = -# = === === = == ==== -# = === === = == = = -# == ===== ==== == -# ======================== -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright (c) 2022 Joe -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the organization nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY JOE ''AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL JOE BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# scrvince -# Mon Apr 11 21:07:45 CEST 2022 -# Joe -# -# Screen setup when I'm at Vince's place - -xrandr --output LVDS-1 --mode 1366x768 --pos 1366x425 --rotate normal -xrandr --output VGA-1 --off -xrandr --output HDMI-1 --primary --mode 1366x768 --pos 0x0 --rotate normal -xrandr --output DP-1 --off -xrandr --output HDMI-2 --off -xrandr --output HDMI-3 --off -xrandr --output DP-2 --off -xrandr --output DP-3 --off -setwp -sysctl hw.snd.default_unit=1 diff --git a/.local/bin/scrvincetv b/.local/bin/scrvincetv deleted file mode 100755 index 044f642..0000000 --- a/.local/bin/scrvincetv +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# ======================== -# ===== =============== -# ====== ================ -# ====== ================ -# ====== ==== ==== == -# ====== === == = = -# ====== === = == = -# = === === = == ==== -# = === === = == = = -# == ===== ==== == -# ======================== -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright (c) 2022 Joe -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the organization nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY JOE ''AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL JOE BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# scrvincetv -# Mon Apr 11 21:08:39 CEST 2022 -# Joe -# -# Screen setup when I'm at Vince's place but watching TV - -xrandr --output LVDS-1 --primary --mode 1366x768 --pos 1920x312 --rotate normal -xrandr --output VGA-1 --off -xrandr --output HDMI-1 --mode 1920x1080 --pos 0x0 --rotate normal -xrandr --output DP-1 --off -xrandr --output HDMI-2 --off -xrandr --output HDMI-3 --off -xrandr --output DP-2 --off -xrandr --output DP-3 --off -setwp -sysctl hw.snd.default_unit=1 diff --git a/.local/bin/scrwork b/.local/bin/scrwork deleted file mode 100755 index 99c5489..0000000 --- a/.local/bin/scrwork +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -# ======================== -# ===== =============== -# ====== ================ -# ====== ================ -# ====== ==== ==== == -# ====== === == = = -# ====== === = == = -# = === === = == ==== -# = === === = == = = -# == ===== ==== == -# ======================== -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright (c) 2022 Joe -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the organization nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY JOE ''AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL JOE BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# scrwork -# Thu Apr 21 14:31:51 CEST 2022 -# Joe -# -# Screen setup when I'm at work - -xrandr \ - --output eDP-1 --mode 1920x1080 --pos 0x0 --rotate normal \ - --output HDMI-1 --primary --mode 1920x1080 --pos 1920x0 --rotate normal \ - --output DP-1 --off \ - --output DP-2 --off -sysctl hw.snd.default_unit=0 >/dev/null -setwp diff --git a/.local/bin/setwp b/.local/bin/setwp index e5fce65..85041ec 100755 --- a/.local/bin/setwp +++ b/.local/bin/setwp @@ -5,6 +5,7 @@ use warnings; use File::HomeDir qw(home); use File::Copy; use File::Find; +use POSIX qw(setsid); use constant { WP_POOL => home() . '/pics/wp/' @@ -37,20 +38,37 @@ sub choose_wp sub set_wp { my ($wp) = @_; + my $pid; + my $old_pid; return 1 if !(-r $wp) || !(-f $wp); - system( - FEH_PATH, - '--no-fehbg', - '--image-bg', - '#1d2021', - '--bg-fill', - $wp, - '--bg-fill', - $wp, - '--bg-fill', - $wp - ); + + if (defined $ENV{WAYLAND_DISPLAY}) { + $old_pid = `pidof wbg`; + chomp $old_pid; + $pid = fork(); + if (not $pid) { + setsid(); + exec("wbg", $wp); + } else { + sleep(1); + exec("kill", $old_pid); + } + } + else { + system( + FEH_PATH, + '--no-fehbg', + '--image-bg', + '#1d2021', + '--bg-fill', + $wp, + '--bg-fill', + $wp, + '--bg-fill', + $wp + ); + } return 0; } diff --git a/.local/bin/synchdd b/.local/bin/synchdd index 642967a..49cc428 100755 --- a/.local/bin/synchdd +++ b/.local/bin/synchdd @@ -25,5 +25,5 @@ rsync -avhk --delete-after \ rsync -avhk --delete-after \ $HOME/vids $dest # sort_dir -rsync -avhk --delete-after \ - $HOME/hdd/sort $dest +#rsync -avhk --delete-after \ +# $HOME/hdd/sort $dest |