summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/backup13
-rwxr-xr-x.local/bin/dmapps217
-rwxr-xr-x.local/bin/dmbookm11
-rwxr-xr-x.local/bin/dmlog43
-rwxr-xr-x.local/bin/dmotp8
-rwxr-xr-x.local/bin/dmpass20
-rwxr-xr-x.local/bin/dmrun6
-rwxr-xr-x.local/bin/linkview714
-rwxr-xr-x.local/bin/mic45
-rwxr-xr-x.local/bin/mixer-set86
-rwxr-xr-x.local/bin/nb1
-rwxr-xr-x.local/bin/ndate5
-rwxr-xr-x.local/bin/newsboat-notif3
-rwxr-xr-x.local/bin/ref-newsboat24
-rwxr-xr-x.local/bin/scr116
-rwxr-xr-x.local/bin/scr221
-rwxr-xr-x.local/bin/scr313
-rwxr-xr-x.local/bin/scrext55
-rwxr-xr-x.local/bin/scrhome59
-rwxr-xr-x.local/bin/scrmain55
-rwxr-xr-x.local/bin/scrvince56
-rwxr-xr-x.local/bin/scrvincetv56
-rwxr-xr-x.local/bin/scrwork53
-rwxr-xr-x.local/bin/setwp59
-rwxr-xr-x.local/bin/synchdd4
25 files changed, 750 insertions, 893 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 51b0625..0ce4c81 100755
--- a/.local/bin/dmapps
+++ b/.local/bin/dmapps
@@ -2,9 +2,9 @@
use strict;
use warnings;
+use feature qw/switch/;
use Data::Dump qw(dump);
use POSIX qw(setsid);
-use Switch;
use Sys::Hostname qw(hostname);
use constant PROG_LIST => "" .
@@ -23,6 +23,7 @@ use constant PROG_LIST => "" .
"Stellarium" . "\n" .
"Google Earth" . "\n" .
"DBeaver" . "\n" .
+"OnlyOffice" . "\n" .
"--- Editors ---" . "\n" .
"NeoVim" . "\n" .
"Emacs" . "\n" .
@@ -40,6 +41,7 @@ use constant PROG_LIST => "" .
"Liferea" . "\n" .
"HexChat" . "\n" .
"--- Audio ---" . "\n" .
+"Ardour" . "\n" .
"REAPER" . "\n" .
"Audacity" . "\n" .
"Pulse Control Panel" . "\n" .
@@ -77,161 +79,58 @@ sub run
$pid = fork();
exit if $pid;
setsid();
- switch ($action) {
- case "Terminal" {
- exec("alacritty");
- }
- case "File manager" {
- exec("pcmanfm");
- }
- case "Web browser" {
- exec("firefox");
- }
- case "Mail client" {
- exec("thunderbird");
- }
- case "Arduino" {
- exec("arduino-ide");
- }
- case "cool-retro-term" {
- exec("cool-retro-term");
- }
- case "Qalculate!" {
- exec("qalculate-gtk");
- }
- case "Kleopatra" {
- exec("kleopatra");
- }
- case "Transmission" {
- exec("transmission-gtk");
- }
- case "Wireshark" {
- exec("doas", "wireshark");
- }
- case "MKVToolNix" {
- exec("mkvtoolnix-gui");
- }
- case "Stellarium" {
- exec("stellarium");
- }
- case "Google Earth" {
- exec("google-earth-pro");
- }
- case "NeoVim" {
- exec("alacritty", "-e", "nvim");
- }
- case "Emacs" {
- exec("emacs");
- }
- case "Emacs-NoX" {
- exec("alacritty", "-e", "emacs-nw");
- }
- case "GIMP - GNU Image Manipulation Program" {
- exec("gimp");
- }
- case "Inkscape" {
- exec("inkscape");
- }
- case "LibreWolf" {
- exec("librewolf");
- }
- case "Firefox" {
- exec("firefox");
- }
- case "Iridium" {
- exec("iridium", "--force-dark-mode");
- }
- case "Chromium" {
- exec("chromium");
- }
- case "Discord" {
- exec("discord");
- }
- case "Signal" {
- exec("signal-desktop");
- }
- case "Liferea" {
- exec("liferea");
- }
- case "HexChat" {
- exec("hexchat");
- }
- case "REAPER" {
- exec("reaper");
- }
- case "Audacity" {
- exec("audacity");
- }
- case "Pulse Control Panel" {
- exec("pavucontrol");
- }
- case "JACK Audio Connection Kit" {
- exec("qjackctl");
- }
- case "Ario" {
- exec("ario");
- }
- case "Kdenlive" {
- exec("kdenlive");
- }
- case "OBS Studio" {
- exec("obs");
- }
- case "Steam" {
- exec("steam");
- }
- case "Lutris" {
- exec("lutris");
- }
- case "GZDoom" {
- exec("gzdoom");
- }
- case "DOSBox" {
- exec("dosbox");
- }
- case "Mupen64Plus" {
- exec("mupen64plus-qt");
- }
- case "Cemu" {
- exec("cemu");
- }
- case "PCSX2" {
- exec("pcsx2");
- }
- case "RPCS3" {
- exec("rpcs3");
- }
- case "Remmina" {
- exec("remmina");
- }
- case "Rclone Browser" {
- exec("rclone-browser");
- }
- case "Insomnia" {
- exec("insomnia");
- }
- case "VMware" {
- exec("vmware");
- }
- case "DBeaver" {
- exec("dbeaver");
- }
- case "MongoDB Compass" {
- exec("nixGL", "mongodb-compass");
- }
- case "Miro" {
- exec("miro");
- }
- case "FortiClient VPN" {
- exec("/opt/forticlient/gui/FortiClient-linux-x64/FortiClient");
- }
- case "Teams" {
- exec("nixGL", "teams-for-linux");
- }
- else {
- return;
- }
- }
+ exec("alacritty") if $action =~ "Terminal";
+ exec("pcmanfm") if $action =~ "File manager";
+ exec("firefox") if $action =~ "Web browser";
+ exec("thunderbird") if $action =~ "Mail client";
+ exec("arduino-ide") if $action =~ "Arduino";
+ exec("cool-retro-term") if $action =~ "cool-retro-term";
+ exec("qalculate-gtk") if $action =~ "Qalculate!";
+ exec("kleopatra") if $action =~ "Kleopatra";
+ exec("transmission-gtk") if $action =~ "Transmission";
+ exec("doas", "wireshark") if $action =~ "Wireshark";
+ exec("mkvtoolnix-gui") if $action =~ "MKVToolNix";
+ exec("stellarium") if $action =~ "Stellarium";
+ exec("google-earth-pro") if $action =~ "Google Earth";
+ exec("alacritty", "-e", "nvim") if $action =~ "NeoVim";
+ exec("emacs") if $action =~ "Emacs";
+ exec("alacritty", "-e", "emacs-nw") if $action =~ "Emacs-NoX";
+ exec("gimp") if $action =~ "GIMP - GNU Image Manipulation Program";
+ exec("inkscape") if $action =~ "Inkscape";
+ exec("librewolf") if $action =~ "LibreWolf";
+ exec("firefox") if $action =~ "Firefox";
+ exec("iridium", "--force-dark-mode") if $action =~ "Iridium";
+ exec("chromium") if $action =~ "Chromium";
+ exec("discord") if $action =~ "Discord";
+ 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";
+ exec("qjackctl") if $action =~ "JACK Audio Connection Kit";
+ exec("ario") if $action =~ "Ario";
+ exec("kdenlive") if $action =~ "Kdenlive";
+ exec("obs") if $action =~ "OBS Studio";
+ exec("steam") if $action =~ "Steam";
+ exec("lutris") if $action =~ "Lutris";
+ exec("gzdoom") if $action =~ "GZDoom";
+ exec("dosbox") if $action =~ "DOSBox";
+ exec("mupen64plus-qt") if $action =~ "Mupen64Plus";
+ exec("cemu") if $action =~ "Cemu";
+ exec("pcsx2") if $action =~ "PCSX2";
+ exec("rpcs3") if $action =~ "RPCS3";
+ exec("remmina") if $action =~ "Remmina";
+ exec("rclone-browser") if $action =~ "Rclone Browser";
+ exec("insomnia") if $action =~ "Insomnia";
+ exec("vmware") if $action =~ "VMware";
+ exec("dbeaver") if $action =~ "DBeaver";
+ exec("onlyoffice-desktopeditors") if $action =~ "OnlyOffice";
+ exec("nixGL", "mongodb-compass") if $action =~ "MongoDB Compass";
+ exec("miro") if $action =~ "Miro";
+ exec("/opt/forticlient/gui/FortiClient-linux-x64/FortiClient") if $action =~ "FortiClient VPN";
+ exec("nixGL", "teams-for-linux") if $action =~ "Teams";
return;
}
@@ -249,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 2bfeb21..dcd0e36 100755
--- a/.local/bin/dmbookm
+++ b/.local/bin/dmbookm
@@ -15,6 +15,7 @@ use constant {
use constant LIST => {
graf => 'http://graf.joe.town/',
zhinu => 'https://zhinu.jozan.org/',
+ claude => 'https://claude.ai',
perplexity => 'https://perplexity.ai/',
chatgpt => 'https://chatgpt.com/',
discord => 'https://discord.com/',
@@ -24,6 +25,7 @@ use constant LIST => {
nua_gr_restops => 'https://grafana.nuabee.fr/d/Mz11bd07k/vue-d-ensemble-machines-atelier',
nua_gr_alertops => 'https://grafana.nuabee.fr/d/WojOgXTmk/ops-alerts',
nua_git => 'https://gitlab.int.ysosecure.com/',
+ nua_pipes => 'https://gitlab.int.ysosecure.com/ops/NuaProv/-/pipelines',
nua_mbs => 'https://mbs.nuabee.com/',
nua_hedgedoc => 'http://hedgedoc.int.ysosecure.com/',
nua_doc => 'https://doc.int.ysosecure.com/',
@@ -31,6 +33,13 @@ use constant LIST => {
nua_zammad => 'https://support.nuabee.fr/',
nua_atlas => 'https://atlas.nuabee.fr/',
nua_share => 'https://share.nuabee.fr/',
+ nua_windmill => 'https://windmill.nuabee.fr/',
+ 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
@@ -50,7 +59,7 @@ sub main
if (HOSTNAME eq "mars") {
$prefix += '/local';
}
- for (keys %{LIST()}) {
+ for (sort keys %{LIST()}) {
$list .= $_ . "\n";
}
$choice = `printf "$list" | dmenu -i -l 100 -sb '$color' -shb '$color'`;
diff --git a/.local/bin/dmlog b/.local/bin/dmlog
index 756d9b9..600e4d4 100755
--- a/.local/bin/dmlog
+++ b/.local/bin/dmlog
@@ -36,8 +36,13 @@ sub confirm
for (@{+CONFIRM}) {
$list .= $_ . "\n";
}
+
+ my $menu = "dmenu -sb '$color' -shb '$color'";
+ if (defined $ENV{WAYLAND_DISPLAY}) {
+ $menu = "wmenu -S '$color'";
+ }
$choice = `printf "%s" "$list" | \
- dmenu -i -p "$var?" -sb '$color' -shb '$color'`;
+ $menu -i -p "$var?"`;
chomp $choice;
if ($choice eq ${+CONFIRM}[1]) {
return (1);
@@ -52,12 +57,29 @@ sub action
chomp $var;
if ($var eq ${+LIST}[0]) {
- exec(XSCREENSAVER_PATH, '-lock');
+ if (defined $ENV{WAYLAND_DISPLAY}) {
+ exec("waylock",
+ "-init-color", "0x1d2021",
+ "-input-color", "0xd79921",
+ "-fail-color", "0xcc241d");
+ }
+ else {
+ exec(SLOCK_PATH);
+ # exec(XSCREENSAVER_PATH, '-lock');
+ }
}
elsif ($var eq ${+LIST}[1]) {
$pid = fork();
if (not $pid) {
- exec(XSCREENSAVER_PATH, '-lock');
+ if (defined $ENV{WAYLAND_DISPLAY}) {
+ exec("waylock",
+ "-init-color", "0x1d2021",
+ "-input-color", "0xd79921",
+ "-fail-color", "0xcc241d");
+ }
+ else {
+ exec(XSCREENSAVER_PATH, '-lock');
+ }
}
else {
system(
@@ -69,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');
}
@@ -88,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,
@@ -117,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');
}
@@ -138,7 +162,12 @@ sub main
for (@{+LIST}) {
$list .= $_ . "\n";
}
- $choice = `printf "%s" "$list" | dmenu -i -sb '$color' -shb '$color'`;
+
+ my $menu = "dmenu -sb '$color' -shb '$color'";
+ if (defined $ENV{WAYLAND_DISPLAY}) {
+ $menu = "wmenu -S '$color'";
+ }
+ $choice = `printf "%s" "$list" | $menu -i`;
action($choice, $color);
return (0);
}
diff --git a/.local/bin/dmotp b/.local/bin/dmotp
index 97f015f..243f48c 100755
--- a/.local/bin/dmotp
+++ b/.local/bin/dmotp
@@ -6,10 +6,10 @@ if echo "$1" | grep '^#' 2>&1; then
fi
if [ -n "$WAYLAND_DISPLAY" ]; then
- dmenu=dmenu-wl
- xdotool="ydotool type --file -"
+ dmenu="wmenu -i -l 15 -S $color"
+ xdotool="ydotool type --delay 15 --file -"
elif [ -n "$DISPLAY" ]; then
- dmenu=dmenu
+ dmenu="dmenu -i -l 15 -sb $color -shb $color"
xdotool="xdotool type --delay 15 --clearmodifiers --file -"
else
echo "Error: No Wayland or X11 display detected" >&2
@@ -19,7 +19,7 @@ fi
prefix=${PASSWORD_STORE_DIR-~/.local/share/pass}/otp
rprefix=$(printf "%s" $prefix | sed 's/\//\\\//g')
password_files=$(ls "$prefix"/*.gpg | sed 's/^'${rprefix}'\///g' | sed 's/\.gpg//g')
-password=$(printf "%s\n" "${password_files}" | "$dmenu" -i -l 15 -sb "$color" -shb "$color")
+password=$(printf "%s\n" "${password_files}" | $dmenu)
[ -n "$password" ] || exit
diff --git a/.local/bin/dmpass b/.local/bin/dmpass
index d5b0494..475b96e 100755
--- a/.local/bin/dmpass
+++ b/.local/bin/dmpass
@@ -13,10 +13,10 @@ fi
if [ -n "$WAYLAND_DISPLAY" ]; then
- dmenu=dmenu-wl
- xdotool="ydotool type --file -"
+ dmenu="wmenu -i -l 15 -S $color"
+ xdotool="ydotool type --delay 15 --file -"
elif [ -n "$DISPLAY" ]; then
- dmenu=dmenu
+ dmenu="dmenu -i -l 15 -sb $color -shb $color"
xdotool="xdotool type --delay 15 --clearmodifiers --file -"
else
echo "Error: No Wayland or X11 display detected" >&2
@@ -26,7 +26,7 @@ fi
prefix=${PASSWORD_STORE_DIR-~/.local/share/pass}
rprefix=$(printf "%s" $prefix | sed 's/\//\\\//g')
password_files=$(ls "$prefix"/*.gpg "$prefix"/*/*.gpg | sed 's/^'${rprefix}'\///g' | sed 's/\.gpg//g')
-password=$(printf "%s\n" "${password_files}" | "$dmenu" -i -l 15 -sb "$color" -shb "$color")
+password=$(printf "%s\n" "${password_files}" | $dmenu)
[ -n "$password" ] || exit
@@ -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 1523e33..68d5bcb 100755
--- a/.local/bin/linkview
+++ b/.local/bin/linkview
@@ -5,53 +5,160 @@ 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 = "fzf";
use constant {
TERMINAL_PATH => $TERMINAL,
MPV_PATH => 'mpv',
YTDL_PATH => 'yt-dlp',
+ IMGVIEW_PATH => 'nsxiv -b -a',
FETCH_PATH => 'fetch',
CURL_PATH => 'curl',
- IMGVIEW_PATH => 'nsxiv',
ZATHURA_PATH => 'zathura',
W3M_PATH => 'w3m',
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" .
-"nsxiv" . "\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;
@@ -61,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;
- }
- elsif ($a eq "mpv-term") {
- exec(TERMINAL_PATH, '-e', MPV_PATH, '--audio-channels=stereo', $url);
+ chomp $quality;
}
- 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" | dmenu -i -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>'
@@ -260,157 +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(IMGVIEW_PATH, '-b', '-a', $file_name);
- unlink($file_name);
- exit 0;
+ return;
}
- }
- elsif ($a eq "nsxiv" || $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 "nsxiv") {
- exec(IMGVIEW_PATH, '-b', '-a', $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" | dmenu -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 98938c5..85041ec 100755
--- a/.local/bin/setwp
+++ b/.local/bin/setwp
@@ -4,6 +4,8 @@ use strict;
use warnings;
use File::HomeDir qw(home);
use File::Copy;
+use File::Find;
+use POSIX qw(setsid);
use constant {
WP_POOL => home() . '/pics/wp/'
@@ -12,11 +14,13 @@ use constant FEH_PATH => 'feh';
sub get_pool_files
{
+ my ($pool) = (@_);
my @files;
- opendir(DIR, WP_POOL) or die "Couldn't open directory " . WP_POOL . ": $!";
- @files = grep { !/^\./ } readdir(DIR);
- closedir(DIR);
+ $pool = WP_POOL if not @_;
+ find(sub {
+ push @files, $File::Find::name if -f;
+ }, $pool);
return @files;
}
@@ -27,27 +31,44 @@ sub choose_wp
my $wp;
$rand = int(rand(@files));
- $wp = WP_POOL . $files[$rand];
+ $wp = $files[$rand];
return $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;
}
@@ -87,8 +108,12 @@ sub main
if (@ARGV != 0 && -f $ARGV[0]) {
$ret = set_wp($ARGV[0]);
}
+ elsif (@ARGV != 0 && -d $ARGV[0]) {
+ $wp = choose_wp(get_pool_files($ARGV[0]));
+ $ret = set_wp($wp);
+ }
else {
- $wp = choose_wp(get_pool_files());
+ $wp = choose_wp(get_pool_files(WP_POOL));
$ret = set_wp($wp);
}
if (@ARGV == 0 || (@ARGV != 0 && $ARGV[0] ne "-nw")) {
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