diff options
Diffstat (limited to '.local/bin')
63 files changed, 1026 insertions, 1954 deletions
| diff --git a/.local/bin/backup b/.local/bin/backup new file mode 100755 index 0000000..5d09ddf --- /dev/null +++ b/.local/bin/backup @@ -0,0 +1,15 @@ +#!/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 "${XDG_DATA_HOME}"/sfeed/ zhinu:/var/mother_backup/newsboat/data/ +rsync -avhz --progress --delete-after "${XDG_CONFIG_HOME}"/sfeed/ 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/bcat b/.local/bin/bcat new file mode 100755 index 0000000..e7286f1 --- /dev/null +++ b/.local/bin/bcat @@ -0,0 +1,7 @@ +#!/bin/sh + +tmp=$(mktemp) +cat - >$tmp +$BROWSER $tmp +sleep 2 +rm $tmp diff --git a/.local/bin/conky/cover.sh b/.local/bin/conky/cover.sh deleted file mode 100755 index d9c9e8c..0000000 --- a/.local/bin/conky/cover.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# cover.sh - Download cover from Last.fm and overlay with image -# -# Florian <floriandejonckheere.be> -# -# bug: it detects the artist change twice - -## CONFIGURATION ## -# Folder for cached album art -# Don't use ~, as conky will treat it as a regular directory name -# CACHE="$HOME/.cache/covers" -# API Key for Last.fm -# APIKEY="b25b959554ed76058ac220b7b2e0a026" -# Log file, only for debugging purposes -# LOG=/tmp/conky-mpd.log -TMP=/tmp/conkympd.tmp - -# Check for vital commands -# CMD="mpc curl convert" -# for CHECK in $CMD; do -# 	[ ! "$CHECK" ] && echo "Command $CHECK not found. Exiting." && exit 1 -# done -# [ ! -d "$CACHE" ] && mkdir -p "$CACHE" - -playing="$(mpc --format '%artist% - %album%' | head -1)" - -[ ! -f $TMP ] && touch $TMP -[ "$(cat $TMP)" = "$playing" ] && exit 0 -# [ "$(cat $TMP)" = "$playing" ] && echo "Same artist/album" >> $LOG && exit 0 -# echo "Artist/album changed: $playing" >> $LOG - -#[ -f "/tmp/conkyCover.png" ] && rm "/tmp/conkyCover.png" -cp "$HOME"/.config/conky-mpd/nocover.png /tmp/conkyCover.png -# echo "NoCover" >> $LOG - -filedir="$(dirname "$XDG_MUSIC_DIR/$(mpc --format %file% | head -n1)")" -coverfile="$(find "$filedir" -maxdepth 1 -type f \( -iname 'cover.jpg' -o -iname 'cover.png' -o -iname 'folder.jpg' -o -iname 'folder.png' -o -iname '*.jpg' -o -iname '*.png' \) -print -quit)" -#COVER="$CACHE/$ARTIST - $ALBUM.jpg" -## Is cover cached? -#if [ ! -f "$COVER" ]; then -## Nope. Download. -#	echo "Downloading cover for $ARTIST - $ALBUM" >> $LOG -#	# Download XML info -#	curl --data-urlencode artist="$ARTIST" --data-urlencode album="$ALBUM" "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=$APIKEY" -o /tmp/lastfm.xml &> /dev/null -#	echo "Exit: $?. Downloaded $(wc -l /tmp/lastfm.xml | cut -d' ' -f1) bytes." >> $LOG -#	# Strip XML and download mega large cover to cache -#	curl $(sed -n 's|<image size="mega">\(.*\)<\/image>|\1|p' /tmp/lastfm.xml) -o "$COVER" &> /dev/null -#	echo "Exit: $?" >> $LOG -#	echo "Downloaded to $COVER." >> $LOG -#fi -# Copy cache for processing -# echo "Copying $coverfile." >> $LOG -# cp "$COVER" /tmp/cover.jpg -# Downscale to fit overlay -# convert /tmp/cover.jpg -resize 366 /tmp/cover.png >> $LOG -## Enlarge canvas to fit overlay -#convert /tmp/cover.png -background none -extent 500x455-84-44 /tmp/cover.png >> $LOG -## Overlay overlay over cover -#convert /tmp/cover.png $HOME/.config/conky-mpd/case.png -composite /tmp/cover.png >> $LOG -## Resize for immediate use -# convert /tmp/cover.png -resize 120 /tmp/conkyCover.png >> $LOG -convert "$coverfile" -resize 100 /tmp/conkyCover.png # >> $LOG -## Set current artist -echo "$playing" > $TMP -#rm /tmp/cover.jpg /tmp/cover.png - diff --git a/.local/bin/conky/getif.sh b/.local/bin/conky/getif.sh deleted file mode 100755 index a4aff49..0000000 --- a/.local/bin/conky/getif.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# ifconfig | command grep '^[a-z]' | awk '{print $1}' | sed '{/lo/d;s/://;}' - -case "$(hostname -s)" in -	mother) -		if_main="eth1" -		if_alt="eth0" -		;; -	po-rbo) -		if_main="enx4ce1734c425a" -		if_alt="wlp1s0" -		;; -	mars) -		if_main="em0" -		if_alt="wlan0" -		exit -		;; -esac - -if grep up "/sys/class/net/$if_main/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_main 2>/dev/null | awk '/inet / {print $2}') ]; then -	: -elif grep up "/sys/class/net/$if_alt/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_alt 2>/dev/null | awk '/inet / {print $2}') ]; then -	if_main=$if_alt -else -	echo '${font1}NETWORK ${hr}${font} -${color #928374}No network${font}' -	exit -fi - -echo -n $if_main diff --git a/.local/bin/conky/net.sh b/.local/bin/conky/net.sh deleted file mode 100755 index 4baf43b..0000000 --- a/.local/bin/conky/net.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -case "$(hostname -s)" in -	mother) -		if_main="eth1" -		if_alt="eth0" -		;; -	po-rbo) -		if_main="enx34298f762de7" -		if_alt="wlp1s0" -		if_vpnssl="vpn0" -		;; -	mars) -		if_main="em0" -		if_alt="wlan0" -		exit -		;; -esac - -if_wg="wg0" -if [ -e "/sys/class/net/$if_wg/operstate" ] && ! [ -z $(ifconfig $if_wg 2>/dev/null | awk '/inet / {print $2}') ]; then -	: -else -	if_wg="" -fi - -if grep up "/sys/class/net/$if_main/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_main 2>/dev/null | awk '/inet / {print $2}') ]; then -	: -elif grep up "/sys/class/net/$if_alt/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_alt 2>/dev/null | awk '/inet / {print $2}') ]; then -	if_main=$if_alt -else -	: -fi - -if [ -z $if_vpnssl ]; then -	: -elif ! ip a | grep $if_vpnssl | grep UP >/dev/null 2>&1; then -	if_vpnssl="" -fi - -echo $if_main'${font}' -[ -z $if_wg ] || echo '${color5}${font2}WireGuard ${color0}${font}ON${font}' -[ -z $if_wg ] || echo '${color5}${font2}WG  IP   ${color0}${font}${goto 80}${addr '$if_wg'}${font}' -[ -z $if_vpnssl ] || echo '${color5}${font2}Forti VPN-SSL ${color0}${font}ON${font}' -[ -z $if_vpnssl ] || echo '${color5}${font2}VPN IP  ${color0}${font}${goto 80}${addr '$if_vpnssl'}${font}' -echo '${voffset 3}${color5}${font2}LAN IP   ${color0}${font}${goto 80}${addr '$if_main'}${font}' -echo '${color5}${font2}DNS IP  ${color0}${font}${goto 80}${nameserver 0}${if_match "${nameserver 1}" != ""}, ${nameserver 1}${endif}${font}' -echo '${color5}${font2}WAN IP ${color0}${font}${goto 80}${execi 15 curl -s https://ifconfig.me || echo No WAN}${font}' diff --git a/.local/bin/dmapps b/.local/bin/dmapps index 51b0625..e5f9dab 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	=> "" . @@ -13,16 +13,12 @@ use constant PROG_LIST	=> "" .  "Web browser"				. "\n" .  "Mail client"				. "\n" .  "--- Accessories ---"		. "\n" . -"Arduino"					. "\n" .  "cool-retro-term"			. "\n" . -"Qalculate!"				. "\n" . -"Kleopatra"					. "\n" . -"Transmission"				. "\n" . -"Wireshark"					. "\n" .  "MKVToolNix"				. "\n" .  "Stellarium"				. "\n" .  "Google Earth"				. "\n" .  "DBeaver"					. "\n" . +"OnlyOffice"				. "\n" .  "--- Editors ---"			. "\n" .  "NeoVim"					. "\n" .  "Emacs"						. "\n" . @@ -40,13 +36,12 @@ use constant PROG_LIST	=> "" .  "Liferea"					. "\n" .  "HexChat"					. "\n" .  "--- Audio ---"				. "\n" . +"Ardour"					. "\n" .  "REAPER"					. "\n" .  "Audacity"					. "\n" .  "Pulse Control Panel"		. "\n" .  "JACK Audio Connection Kit"	. "\n" .  "--- Multimedia ---"		. "\n" . -"Ario"						. "\n" . -"Kdenlive"					. "\n" .  "OBS Studio"				. "\n" .  "--- Games ---"				. "\n" .  "Steam"						. "\n" . @@ -75,163 +70,53 @@ sub run  	chomp($action);  	$pid = fork(); -	exit if $pid; +	return 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("st") if $action =~ "Terminal"; +	exec("st", "-e", "nnn") if $action =~ "File manager"; +	exec("firefox") if $action =~ "Web browser"; +	exec("st", "-e", "neomutt") if $action =~ "Mail client"; +	exec("cool-retro-term") if $action =~ "cool-retro-term"; +	exec("mkvtoolnix-gui") if $action =~ "MKVToolNix"; +	exec("stellarium") if $action =~ "Stellarium"; +	exec("google-earth-pro") if $action =~ "Google Earth"; +	exec("st", "-e", "nvim") if $action =~ "NeoVim"; +	exec("emacs") if $action =~ "Emacs"; +	exec("st", "-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("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 +134,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 90b7c74..7578500 100755 --- a/.local/bin/dmbookm +++ b/.local/bin/dmbookm @@ -3,27 +3,28 @@  use strict;  use warnings;  use Sys::Hostname; - -# debug -use Data::Dumper; +use Env qw(BROWSER);  use constant { -	BROWSER		=> '/bin/firefox',  	HOSTNAME	=> (split /\./, hostname())[0]  };  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/',  	protondb				=> 'https://www.protondb.com/', +	vultr					=> 'https://my.vultr.com/', +	epik					=> 'https://epik.com/',  	nua_grafana				=> 'https://grafana.nuabee.fr/',  	nua_gr_linux_servers	=> 'https://grafana.nuabee.fr/d/xfpJB9FGz/linux-servers',  	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,9 +32,14 @@ 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_cert				=> 'https://orca1.int.ysosecure.com/certsrv', +	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/', +	nua_nm					=> 'https://dashboard.nm.nuabee.fr/',  };  sub main @@ -41,7 +47,6 @@ sub main  	my $choice;  	my $url;  	my $pid; -	my $prefix;  	my $list;  	my $color; @@ -49,10 +54,6 @@ sub main  	if (@ARGV == 1) {  		$color = $ARGV[0];  	} -	$prefix = '/usr'; -	if (HOSTNAME eq "mars") { -		$prefix += '/local'; -	}  	for (sort keys %{LIST()}) {  		$list .= $_ . "\n";  	} @@ -63,7 +64,7 @@ sub main  	chomp $choice;  	$pid = fork();  	if (not $pid) { -		exec($prefix . BROWSER, LIST->{$choice}); +		exec($BROWSER, '--new-window', LIST->{$choice});  	}  	return;  } diff --git a/.local/bin/dmhc b/.local/bin/dmhc new file mode 100755 index 0000000..39e6e12 --- /dev/null +++ b/.local/bin/dmhc @@ -0,0 +1,85 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use POSIX qw(setsid); + +use constant PIDFILE => '/tmp/halfcab.pid'; + + +my @keys = ( +	'warm', +	'warmy', +	'sex', +	'purp', +	'blues', +	'burn', +	'white', +	'off', +	'scr', +); + +my @values = ( +	'hc 85 30 0', +	'hc 214 90 10', +	'hc 255 0 0', +	'hc 255 0 255', +	'hc 150 150 255', +	'hc 214 50 0', +	'hc 255 200 150', +	'hc 0 0 0', +	'', +); + +my %list; +@list{@keys} = @values; + +sub dmhc +{ +	my $choice; +	my $url; +	my $pid; +	my $prefix; +	my $list; +	my $color; +	my $read_pid; + +	$color = '#cc241d'; +	if (@ARGV == 1) { +		$color = $ARGV[0]; +	} +	$list = join("\n", @keys); +	$choice = `printf "$list" | dmenu -i -sb '$color' -shb '$color'`; +	chomp($choice); +	return unless exists $list{$choice}; +	if (-e PIDFILE) { +		open(my $fh, '<', PIDFILE); +		$read_pid = <$fh>; +		chomp($read_pid); +		close($fh); +		kill('TERM', $read_pid); +		while (kill(0, $read_pid) != 0) { +			sleep(0.05); +		} +		unlink(PIDFILE); +	} +	$pid = fork(); +	if ($pid > 0 && $choice eq 'scr') { +		open(my $fh, '>', PIDFILE) or die $!; +		print $fh $pid; +		close($fh); +	} elsif (not $pid) { +		exec($list{$choice}) if $choice ne 'scr'; +		setsid(); +		my $grep = system( +			'xrandr | command grep -E "DP-4.+\+1920" >/dev/null 2>&1' +		); +		exec('hc 1920') if not $grep; +		exec('hc'); +	} +	return; +} + +dmhc(); + +__END__ diff --git a/.local/bin/dmlog b/.local/bin/dmlog index 756d9b9..a5f9b15 100755 --- a/.local/bin/dmlog +++ b/.local/bin/dmlog @@ -12,7 +12,7 @@ use constant {  	KILL_PATH			=> '/usr/bin/killall',  	SHUTDOWN_PATH		=> '/sbin/shutdown',  	LOGINCTL_PATH		=> '/usr/bin/loginctl', -	NOTIF_PATH			=> 'notify-send', +	NOTIF_PATH			=> '/usr/local/bin/herbe',  	HOSTNAME			=> (split /\./, hostname())[0]  };  use constant LIST => [ @@ -27,6 +27,17 @@ use constant CONFIRM => [  	"yes"  	]; +sub notify +{ +	my ($str) = @_; + +	my $pid = fork(); +	if (not $pid) { +		exec(NOTIF_PATH, $str); +	} +	return; +}; +  sub confirm  {  	my ($var, $color) = @_; @@ -36,8 +47,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,27 +68,38 @@ 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 herbe 'welcome back, partner!'"); +		}  	}  	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( -				NOTIF_PATH, -				'-u', -				'normal', -				'shutdown', -				'  g\'night, partner!' -			); +			notify("g'night, partner!");  			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,36 +115,25 @@ 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, -				'-u', -				'normal', -				'shutdown', -				'  rebootin\', partner!' -				); +			notify("rebootin', partner!");  			exec(SHUTDOWN_PATH, '-r', 'now');  		}  	}  	elsif ($var eq ${+LIST}[4]) {  		if (confirm($var, $color) == 1) { -			system( -				NOTIF_PATH, -				'-u', -				'normal', -				'shutdown', -				'  farewell, partner!' -				); +			notify("farewell, partner!");  			sleep 2;  			if (HOSTNAME eq 'mother') {  				exec(LOGINCTL_PATH, 'poweroff');  			}  			elsif (HOSTNAME eq 'po-rbo') { -				exec('systemctl', 'poweroff'); +				exec('doas', 'systemctl', 'poweroff');  			}  			exec(SHUTDOWN_PATH, '-p', 'now');  		} @@ -138,7 +154,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..c315be1 100755 --- a/.local/bin/dmpass +++ b/.local/bin/dmpass @@ -1,5 +1,6 @@  #!/bin/sh +name=0  full=0  color='#cc241d';  if [ "$1" = "--full" ]; then @@ -7,16 +8,21 @@ if [ "$1" = "--full" ]; then  	if echo "$2" | grep '^#' 2>&1; then  		color="$2"  	fi +elif [ "$1" = "--name" ]; then +	name=1 +	if echo "$2" | grep '^#' 2>&1; then +		color="$2" +	fi  elif echo "$1" | grep '^#' 2>&1; then  	color="$1"  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,19 +32,34 @@ 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  p="$(pass show "$password")" -if [ $full -eq 1 ]; then +if [ $full -eq 1 ] || [ $name -eq 1 ]; then  	id=$(printf "%s" "$password" | sed 's/.*___//')  	printf "%s\n" $id | { IFS= read -r pass; printf %s "$id"; } | $xdotool -	xdotool key Tab -	printf "%s\n" "$p" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool -	xdotool key Return -	exit +	if [ $name -eq 1 ]; then +		exit +	fi +fi + +if [ $full -eq 1 ]; then +	if [ -n "$WAYLAND_DISPLAY" ]; then +		ydotool key 15:1 15:0 +	else +		xdotool key Tab +	fi  fi  printf "%s\n" "$p" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool + +if [ $full -eq 1 ]; then +	if [ -n "$WAYLAND_DISPLAY" ]; then +		ydotool key 28:1 28:0 +	else +		xdotool key Return +	fi +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/dmscrot b/.local/bin/dmscrot index dcefb70..b23d886 100755 --- a/.local/bin/dmscrot +++ b/.local/bin/dmscrot @@ -3,12 +3,13 @@  use strict;  use warnings;  use File::HomeDir qw(home); +  use constant {  	SAVE_PATH		=> 'pics/scrot/',  	SCREENSHOT_PATH	=> 'scrot',  	IMGVIEW_PATH	=> 'nsxiv',  	XCLIP_PATH		=> 'xclip', -	NOTIFY_PATH		=> 'notify-send' +	NOTIFY_PATH		=> 'herbe'  };  use constant LIST => [  	'select region', @@ -33,15 +34,15 @@ sub show_img  sub notify_img  {  	my ($file) = @_; +	my $pid; -	system( -		NOTIFY_PATH, -		'-u', 'low', -		'-t', '2000', -		'scrot', -		' screenshot captured to ' . "\n" . -		'<b>' . $file . '</b>' +	$pid = fork(); +	if (not $pid) { +		system( +			NOTIFY_PATH, +			'screenshot captured to ' . "\n" . $file  		); +	}  	return;  } diff --git a/.local/bin/dtinit b/.local/bin/dtinit deleted file mode 100755 index b583bb5..0000000 --- a/.local/bin/dtinit +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -startif() { -	pgrep "$1" >/dev/null || "$@" >/dev/null 2>&1 & -} - -sysctl hw.snd.default_unit=4 -pgrep musicpd >/dev/null || musicpd >/dev/null 2>&1 -# "$HOME"/.local/bin/setwp -"$HOME"/.local/bin/kb -xset s off -xset -dpms -startif dunst -startif picom -startif lowbat -startif mpd-notification -startif xscreensaver --no-splash -# ekb -cd "$HOME" -xrdb "$HOME"/.config/x11/xresources -notify-send -u normal 'Welcome' "  Welcome back, partner\!" -# dbus-launch dwm diff --git a/.local/bin/fetch_mail b/.local/bin/fetch_mail new file mode 100755 index 0000000..04df4b3 --- /dev/null +++ b/.local/bin/fetch_mail @@ -0,0 +1,125 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Fcntl; +use Env qw(HOME); + +use constant MC_FILE_PATH => '/tmp/mc_'; + +sub test_gpg +{ +	my $ret; + +	$ret = system("echo test | gpg2 --sign --batch --no-tty --pinentry-mode error -o /dev/null >/dev/null 2>&1"); +	if ($ret != 0) { +		notify("[!] gpg locked | can't fetch mails"); +	} +	return $ret; +} + +sub notify +{ +	my ($str) = @_; +	my $pid; + +	$pid = fork(); +	if (not $pid) { +		exec('herbe', $str); +	} +	return; +} + +sub get_new_mail +{ +	my ($acc) = @_; +	my $ret; + +	$ret = system('mbsync', $acc); +	if ($ret != 0) { +		notify("[!] $acc: failed to sync mails"); +	} +	return; +} + +sub get_all_accounts +{ +	my @accs; + +	opendir(my $dh, $ENV{'MAIL'}) or die $!; +	@accs = grep { !/^\./ } readdir($dh); +	closedir($dh); +	return @accs; +} + +sub count_new_mails +{ +	my ($acc) = @_; +	my $count; +	my $dir; +	my $path = $ENV{'MAIL'} . '/' . $acc . '/INBOX/new'; + +	$count = 0; +	opendir(my $dh, $path) or die $!; +	$count = grep { -f "$path/$_"} readdir($dh); +	closedir($dh); +	return $count; +} + +sub fetch_thread +{ +	my ($acc) = @_; + +	my $pre_count = -1; +	my $mc_file = MC_FILE_PATH . $acc; +	my $fh; +	if (-f $mc_file) { +		open($fh, '+<', $mc_file) or die $!; +		$pre_count = <$fh>; +	} else { +		open($fh, '+>', $mc_file) or die $!; +		$pre_count = -1; +	} +	get_new_mail($acc); +	my $post_count = count_new_mails($acc); +	if ($post_count > $pre_count && $post_count > 0) { +		my $notify_str = '[mail] ' . $acc . ': ' . $post_count . ' new mail'; +		$notify_str .= ($post_count > 1 ? "s\n" : "\n"); +		notify($notify_str) +	} +	seek($fh, 0, 0); +	print $fh "$post_count"; +	close($fh); +	return; +} + +sub fetch_mail +{ +	$ENV{'MAIL'} = $HOME . '/.local/share/mail'; +	$ENV{'GNUPGHOME'} = $HOME . '/.local/share/gnupg'; +	$ENV{'PASSWORD_STORE_DIR'} = $HOME . '/.local/share/pass'; +	my @pids; +	my $ret; + +	$ret = test_gpg(); +	if ($ret != 0) { +		return; +	} +	system('killall mbsync >/dev/null 2>&1'); +	my @accs = get_all_accounts(); +	for (@accs) { +		my $pid = fork(); +		if (not $pid) { +			fetch_thread($_); +			return; +		} +		push(@pids, $pid); + +	} +	while (wait() != -1) {} +	return; +} + +fetch_mail(); + +__END__ diff --git a/.local/bin/fetch_mail.sh b/.local/bin/fetch_mail.sh deleted file mode 100755 index ed3da4a..0000000 --- a/.local/bin/fetch_mail.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -set -f -set +f -set -m - -export GNUPGHOME=$HOME/.local/share/gnupg -export PASSWORD_STORE_DIR=$HOME/.local/share/pass - -mc_file="/tmp/newmailcount" -if [ -f $mc_file ]; then -	pre_count=$(cat $mc_file) -else -	pre_count="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new | wc -l 2>/dev/null)" -	mb1="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new | wc -l 2>/dev/null)" -	mb2="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new | wc -l 2>/dev/null)" -	pre_count="$((pre_count + mb1 + mb2))" -fi - -if ! echo test | gpg2 --sign --batch --no-tty --pinentry-mode error -o /dev/null >/dev/null 2>&1; then -	notify-send -u low -t 6000 'mbsync' '  GPG locked' -	exit 1 -fi -killall mbsync >/dev/null 2>&1 -notify-send -u low -t 3000 'mbsync' '  fetching mail...' >/dev/null 2>&1 -# { -mbsync -a -c /usr/home/jozan/.config/mbsync/mbsyncrc || -	notify-send -u low -t 6000 'mbsync' '  failed to fetch mail' >/dev/null 2>&1 -# }& -# gsleep 0.2 -# kill -74 $(pidof dwmblocks) >/dev/null 2>&1 -# fg -pre_count="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new | wc -l 2>/dev/null)" -mb1="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new | wc -l 2>/dev/null)" -mb2="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new | wc -l 2>/dev/null)" -post_count="$((post_count + mb1 + mb2))" -if [ $post_count -gt $pre_count ]; then -	notify-send -u normal 'NeoMutt' '  '$post_count' new mail(s)' -fi -echo $post_count >$mc_file -# sleep 1 -# kill -74 $(pidof dwmblocks) >/dev/null 2>&1 diff --git a/.local/bin/fetch_sfeed b/.local/bin/fetch_sfeed new file mode 100755 index 0000000..3588ea2 --- /dev/null +++ b/.local/bin/fetch_sfeed @@ -0,0 +1,18 @@ +#!/bin/sh + +pre=$(wc -l $XDG_DATA_HOME/sfeed/feeds/* | +	tail -n1 | +	rev | +	cut -b 7- | +	rev | +	tr -d ' ') +sfeed_update $XDG_CONFIG_HOME/sfeed/sfeedrc +post=$(wc -l $XDG_DATA_HOME/sfeed/feeds/* | +	tail -n1 | +	rev | +	cut -b 7- | +	rev | +	tr -d ' ') +if [ $post -gt $pre ]; then +	exec herbe "[rss] $((post-pre)) new articles" & +fi diff --git a/.local/bin/hddmnt b/.local/bin/hddmnt index 8ede464..d7115f1 100755 --- a/.local/bin/hddmnt +++ b/.local/bin/hddmnt @@ -7,39 +7,38 @@ case "$(hostname -s)" in  	mother|po-rbo)  		dev=$(find /dev/sd* -type b -exec bash -c 'doas cryptsetup isLuks {} && echo {}' \; | head -n1)  		if [ -z "$dev" ]; then -			notify-send -u critical 'exthdd' '  crypt dev not detected' +			herbe 'crypt dev not detected' &  			exit 1  		fi  		if ! doas cryptsetup open "$dev" "$devname"; then -			notify-send -u critical 'exthdd' "  failed to uncrypt dev <b>$dev</b>" +			herbe "failed to uncrypt dev $dev" &  			exit 1  		fi  		mkdir -p "$mountpoint"  		if ! doas mount /dev/mapper/"$devname" "$mountpoint"; then -			notify-send -u critical 'exthdd' "  failed to mount dev <b>$dev</b>" +			herbe "failed to mount dev $dev" &  			exit 1  		fi -		notify-send -t 5000 'exthdd' "  crypt dev mounted to <b>$mountpoint</b>" +		herbe "crypt dev mounted to $mountpoint" &  		;; -	mars)  +	mars)  		if ! diskinfo da0 >/dev/null; then -			notify-send -u critical 'fathdd' '  HDD not detected' +			herbe 'hdd not detected' &  			exit 1  		fi  		if mount | grep -F /dev/da0p1; then -			notify-send -u critical \ -				'fathdd' \ -				"  HDD already mounted to \ -				<b>$(mount | grep -F '/dev/da0p1' | awk '{print $3}')</b>" +			herbe \ +				"hdd already mounted to \ +				$(mount | grep -F '/dev/da0p1' | awk '{print $3}')"  							exit 1  		fi  		if ! dmenu -m 0 -p 'Enter password: ' -P |  			geli attach -k /root/geli_keys/fathdd_ext.key -j - da0p1; then -					notify-send -u critical 'fathdd' '  Failed to mount HDD' +					herbe 'failed to mount hdd' &  					exit 1  		fi  		mkdir -p "$HOME"/hdd  		mount /dev/da0p1.eli "$HOME"/hdd -		notify-send -t 5000 'fathdd' '  HDD mounted to <b>~/hdd</b>' +		herbe 'hdd mounted to ~/hdd' &  		;;  esac diff --git a/.local/bin/hddumnt b/.local/bin/hddumnt index 9a5319b..d4034ae 100755 --- a/.local/bin/hddumnt +++ b/.local/bin/hddumnt @@ -6,25 +6,25 @@ mountpoint="$HOME/$devname"  case "$(hostname -s)" in  	mother|po-rbo)  		if ! doas umount "$mountpoint"; then -			notify-send -u critical 'exthdd' "  failed to dismount <b>$mountpoint</b>" +			herbe "failed to dismount $mountpoint" &  		fi  		if ! doas cryptsetup close "$devname"; then -			notify-send -u critical 'exthdd' "  failed to close crypt dev <b>$devname</b>" +			herbe "failed to close crypt dev $devname" &  		fi  		rmdir "$mountpoint" -		notify-send -t 5000 'exthdd' "  crypt dev dismounted from <b>$mountpoint</b>" +		herbe "crypt dev dismounted from $mountpoint" &  		;;  	mars)  		if ! mount | grep -F /dev/da0p1; then -			notify-send -u critical 'fathdd' '  HDD not mounted' +			herbe 'hdd not mounted' &  			exit 1  		fi  		if ! umount /dev/da0p1.eli; then -			notify-send -u critical 'fathdd' '  Failed to dismount HDD' +			herbe 'failed to dismount hdd' &  			exit 1  		fi  		geli detach da0p1.eli  		rmdir "$HOME"/hdd -		notify-send -t 5000 'fathdd' '  HDD dismounted from <b>~/hdd</b>' +		herbe 'hdd dismounted from ~/hdd' &  		;;  esac diff --git a/.local/bin/idea b/.local/bin/idea index c3fc9b4..91f8244 100755 --- a/.local/bin/idea +++ b/.local/bin/idea @@ -1,32 +1,34 @@  #!/bin/sh -e -if [ -z "$1" ]; then +title="untitled" + +if [ -z "$2" ]; then  	thought=$(cat -) -elif [ -f "$1" ]; then -	thought=$(cat "$1") +	title="$1" +elif [ -f "$2" ]; then +	thought=$(cat "$2") +	title="$1"  else -	thought="$*" +	thought="${*:2}" +	title="$1"  fi  thought="$(printf "%s" "${thought}" | sed '{s#^#\\t\\t\\t\\t\\t#;s#^\\t\\t\\t\\t\\t$#\\t\\t\\t\\t</p>\\\n\\t\\t\\t\\t<p>#;s#$#\\#;}')"  date=$(date '+%a, %d %b %Y %H:%M') -html_fmt='\t\t\t\t<h3>'"${date}"'</h3>\ +html_fmt='\t\t\t\t<h3>'"${title}"'</h3>\ +\t\t\t\t<h5>'"${date}"'</h5>\  \t\t\t\t<p>\  '"${thought}"'  \t\t\t\t</p>\  '  rss_fmt='\\t<item>\ -\t  <title>'"${date}"'</title>\ -\t  <pubDate>'"${date} $(date '+%Z')"'</pubDate>\ -\t  <link>http://jozan.org/thoughts.html</link>\ -\t  <guid isPermalink="false">'"$(uuidgen)"'</guid>\ -\t  <description>\ -\t\t<![CDATA[\ -\t\t\t\t<p>\ -'"${thought}"' -\t\t\t\t</p>\ -\t\t]]>\ -\t  </description>\ +\t\t<title>'"${title}"'</title>\ +\t\t<pubDate>'"${date} $(date '+%Z')"'</pubDate>\ +\t\t<author>joe</author> +\t\t<guid isPermalink="false">'"$(uuidgen)"'</guid>\ +\t\t<description>\ +\t\t\t'"${thought}"' +\t\t</description>\  \t</item>  ' diff --git a/.local/bin/install-port b/.local/bin/install-port deleted file mode 100755 index 83ec07c..0000000 --- a/.local/bin/install-port +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; -use Term::ANSIColor; - -sub upgrdports { -	my $upgrd_nbr_cmd = "/usr/sbin/pkg version -l '<' | /usr/bin/wc -l | /usr/bin/awk '{print \$1}'"; -	if (system( -			'/usr/local/bin/doas', -			'/usr/sbin/pkg', -			'update' -		) != 0) { -		exit; -	} -	if (system( -			'/usr/local/bin/doas', -			'/usr/sbin/portsnap', -			'fetch', -			'update' -		) != 0) { -		exit; -	} -	print colored("\nPorts to be updated: ", 'bold'); -	my $upgrd_nbr = `$upgrd_nbr_cmd`; -	chomp $upgrd_nbr; -	print colored($upgrd_nbr, 'bold green') . "\n"; -	open(PS, "/usr/sbin/pkg version -l '<' |"); -	while (<PS>) { -		print -	} -	close(PS); -	if ($upgrd_nbr == 0) { -		print colored("No ports to be updated.\n", 'bold green'); -		exit; -	} -	print colored("\nUpgrade these ports? ", 'bold yellow') -		. colored('[', 'bold green') -		. colored('y', 'bold red') -		. colored('/N', 'bold green') -		. colored("]\n", 'bold green') -		. colored("~> ", 'yellow'); -	my $answer = <STDIN>; -	chomp $answer; -	if ($answer ne "y" && $answer ne "Y") { -		print "Exiting...\n"; -		exit; -	} -	system('/usr/local/bin/dash', -		   '-c', -		   '/usr/local/bin/notify-send "Initiating upgrade" "Ports upgrade has started\nTotal: ' . $upgrd_nbr . ' to be updated" >/dev/null 2>&1'); -	if (system('/usr/local/bin/dash', -			   '-c', -			   '/usr/local/bin/doas /usr/local/sbin/portmaster -dya --no-confirm') == 0) { -		my $failed_nbr = `$upgrd_nbr_cmd`; -		chomp $failed_nbr; -		my $diff_nbr = $upgrd_nbr - $failed_nbr; -		system('/usr/local/bin/dash', -			   '-c', -			   '/usr/local/bin/notify-send "Upgrade complete!" "Ports upgrade installed successfully\nTotal: ' . $diff_nbr . ' installed" >/dev/null 2>&1'); -	} -	else { -		my $failed_nbr = `$upgrd_nbr_cmd`; -		substr($failed_nbr, -1) = ""; -		my $diff_nbr = $upgrd_nbr - $failed_nbr; -		system('/usr/local/bin/dash', -			   '-c', -			   '/usr/local/bin/notify-send -u critical -t 10000 "Upgrade failed!" "Some ports failed to compile\nTotal: ' . $diff_nbr . ' installed - ' . $failed_nbr . ' failed" >/dev/null 2>&1'); -	} -	exit; -} - -sub configport { -	my $port = $_[0]; -	my $port_basename = $_[1]; -	if (system( -			'/usr/local/bin/doas', -			'/usr/bin/make', -			'config-recursive') == 0) { -		if (system( -				'/usr/local/bin/doas', -				'/usr/bin/make', -				'config-recursive') == 0) { -			if (system( -					'/usr/local/bin/doas', -					'/usr/bin/make', -					'config-recursive') == 0) { -			} -			system( -				'/usr/local/bin/notify-send', -				'Configuration success!', -				'Ports config - ' . $port . ' - configured successfully', -				); -		} -	} -	else { -		system( -			'/usr/local/bin/notify-send', -			'-u', -			'critical', -			'-t', -			'10000', -			'Configuration failure!', -			'Ports config - ' . $port . ' - failed to configure' -			); -	} -} - -sub installport { -	my $port = $_[0]; -	my $port_basename = $_[1]; -	if (system( -			'/usr/local/bin/doas', -			'/usr/bin/make', -			'install', -			'clean' -		) == 0) { -		system( -			'/usr/local/bin/notify-send', -			'Compilation success!', -			'Ports - ' . $port . ' - installed successfully' -			); -	} -	else { -		system( -			'/usr/local/bin/notify-send', -			'-u', -			'critical', -			'-t', -			'10000', -			'Compilation failure!', -			'Ports - ' . $port . ' - failed to install' -			); -	} -} - -sub main { -	my $argc = $#ARGV + 1; -	if ($argc == 0) { -		print colored("Failed!\n", 'bold red') -			. "No port or argument specified\n"; -		exit 1; -	} -	my $port = $ARGV[0]; -	if ($ARGV[0] eq "upgrade") { -		upgrdports(); -	} -	elsif (-d "/usr/ports/" . $port) { -		my $port_basename = `echo $ARGV[0] | awk -F '/' '{print \$2}'`; -		print colored("Port ", 'bold') -			. colored($port, 'bold green') -			. colored(" found\n", 'bold'); -		chdir "/usr/ports/" . $port; -		configport($port, $port_basename); -		installport($port, $port_basename); -	} -	else { -		print colored("Failed!\n", 'bold red') -			. "Port " -			. colored($port, 'bold yellow') -			. " doesn't exist in " -			. colored("/usr/ports/\n", 'bold'); -	} -	exit; -} - -main(); - -__END__ diff --git a/.local/bin/kb b/.local/bin/kb index c7d9bcf..32cf2a2 100755 --- a/.local/bin/kb +++ b/.local/bin/kb @@ -57,7 +57,7 @@ config_keyboard() {  		xmodmap -e 'keycode 23 = Escape'  		xmodmap -e 'keycode 37 ='  	fi -	notify-send -u low -t 2000 'kb' '  kb set' +	herbe 'kb set' &  }  config_keyboard diff --git a/.local/bin/linkview b/.local/bin/linkview index 1523e33..7cb1ba4 100755 --- a/.local/bin/linkview +++ b/.local/bin/linkview @@ -5,53 +5,144 @@ 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;  use constant { -	TERMINAL_PATH	=> $TERMINAL, -	MPV_PATH		=> 'mpv', -	YTDL_PATH		=> 'yt-dlp', -	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()) +	TERMINAL_PATH	 => $TERMINAL, +	MPV_PATH		 => 'mpv', +	YTDL_PATH		 => 'yt-dlp', +	IMGVIEW_PATH	 => 'nsxiv -b -a', +	FETCH_PATH		 => 'fetch', +	CURL_PATH		 => 'curl', +	ZATHURA_PATH	 => 'zathura', +	W3M_PATH		 => 'w3m', +	BROWSER_PATH	 => $BROWSER, +	ALT_BROWSER_PATH => 'surf', +	NOTIFYSEND_PATH	 => 'herbe', +	COPYQ_PATH		 => 'copyq', +	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', 'surf', 'web', 'clip' ); +my @func_refs = ( \&vid, \&img_pdf, \&dl, \&audio, \&img_pdf, \&w3m, \&surf, \&web, \&clip ); +my %func_list; +@func_list{@keys} = @func_refs; + +my $menu = "fzf --prompt "; +for (@ARGV) { +	$menu = "dmenu -i -l " . scalar @keys . " -p " if $_ eq "--dmenu"; +} +  use constant QUAL_LIST	=> "" . -"1440"					. "\n" . -"1080"					. "\n" . -"720"					. "\n" . -"480"					. "\n" . -"360"					. "\n" . -"240"					. "\n" . -"144"					. "\n" . -"uncap"					. "\n"; - -sub open_link +"uncap"		. "\n" . +"1440"		. "\n" . +"1080"		. "\n" . +"720"		. "\n" . +"480"		. "\n" . +"360"		. "\n" . +"240"		. "\n" . +"144"		. "\n"; + +sub notify +{ +	my ($str) = @_; + +	my $pid = fork(); +	if (not $pid) { +		exec(NOTIFYSEND_PATH, $str); +	} +	return; +}; + +sub vid +{ +	my ($url, $article_name) = @_; +	my $pid; + +	$article_name = "some media" unless defined $article_name; +	$pid = fork(); +	if (not $pid) { +		setsid(); +		close_io(); +		notify('  playing ' . $article_name); +		if (system(MPV_PATH, "--force-window=yes", $url) != 0) { +			notify('  failed to open ' . $url); +		} +		return; +	} +	return; +} + +sub img_pdf +{ +	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" unless defined $article_name; +	$pid = fork(); +	if (not $pid) { +		setsid(); +		close_io(); +		chdir '/tmp' or die $!; +		$file_name = $url; +		$file_name =~ s/.+\///g; +		if (is_yt($url) != 0) { +			notify('  fetching thumbnail for ' . $article_name); +			($tmp, undef, $ret) = capture { +				system(YTDL_PATH, '--get-thumbnail', $url); +			}; +			chomp $tmp; +			if ($ret != 0) { +				notify('  failed to get thumbail for ' . $article_name); +				return; +			} +			$url = $tmp; +		} +		else { +			notify('  fetching ' . $file_name . ' to /tmp'); +		} +		$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) { +			notify('  failed to open file /tmp/'. $new_file_name); +		} +		unlink($new_file_name); +		return; +	} +	return; +} + +sub dl  { -	my ($a, $url) = @_; +	my ($url) = @_;  	my $count;  	my $file_name;  	my $i; @@ -61,356 +152,291 @@ 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 '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]+/\[\.\.\.\]/; +		notify('  downloading ' . $file_name); +		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>' -						); +					notify('  ' . $file_name . ' downloaded successfully to ' . $pwd);  				}  				else { -					system( -						NOTIFYSEND_PATH, -						'-u', 'critical', -						'-t', '10000', -						'download failed', -						'  failed to download <b>' . $file_name . '</b>' -						); +					notify('  failed to download ' . $file_name);  				} +				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) { -				system( -					NOTIFYSEND_PATH, -					'-u', 'critical', -					'-t', '10000', -					'failed to get thumbnail', -					'  failed to get thumbail for <b>'. $file_name . '</b>' -					); -				exit 0; +			elsif ($pid2 < 0) { +				notify('  failed to fork(2)'); +				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) { +						notify('  downloading ' . $file_name . ': +							' . $val); +						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) { +				notify('  ' . $file_name . ' downloaded successfully to ' . $pwd);  			}  			else { -				exec(ZATHURA_PATH, $file_name); +				notify('  failed to download ' . $file_name);  			}  		} +		return;  	} -	elsif ($a eq "w3m") { -		exec(TERMINAL_PATH, '-e', W3M_PATH, $url); +	elsif ($pid < 0) { +		notify('  failed to fork(2)'); +		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(); +		notify('  playing ' . $article_name); +		if (system( +				TERMINAL_PATH, +				"-e", +				MPV_PATH, +				"--vo=null", +				"--video=no", +				"--no-video", +				$url +			) != 0) { +			notify('  failed to open ' . $url);  		} +		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) { +			notify('  failed to open ' . $url); +		} +		return; +	} +	return; +} + +sub surf +{ +	my ($url) = @_; +	my $pid; + +	$pid = fork(); +	if (not $pid) { +		setsid(); +		close_io(); +		exec(ALT_BROWSER_PATH, $url); +	} +	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);  		}  	} +	notify('  clipped url');  	return;  } -sub dmenu_prompt +sub close_io +{ +	open STDIN,  '<', '/dev/null' or die $!; +	open STDOUT, '>', '/dev/null' or die $!; +	open STDERR, '>', '/dev/null' or die $!; +	return; +} + +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; + +	notify('  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 '$url > '`;  	chomp $answer;  	return $answer;  } -sub main +sub linkview  {  	my $answer; -	if (@ARGV == 0) { +	if ((@ARGV == 0 or $ARGV[0] eq '') or +		(@ARGV == 1 and $ARGV[0] eq '--dmenu')) {  		print STDERR "linkview: no URL\n";  		exit 1;  	} -	$answer = dmenu_prompt($ARGV[0]); -	open_link($answer, $ARGV[0]); + +	$answer = fzf_prompt($ARGV[0]); +	$ARGV[1] = undef if (exists $ARGV[1] and $ARGV[1] eq '--dmenu'); +	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..67a9bfa 100755 --- a/.local/bin/mic +++ b/.local/bin/mic @@ -3,50 +3,59 @@  use strict;  use warnings;  use Capture::Tiny qw(capture); +use Sys::Hostname qw(hostname);  use constant {  	MIXER_PATH	=> '/usr/sbin/mixer', -	NOTIF_PATH	=> '/usr/local/bin/notify-send' +	NOTIF_PATH	=> '/usr/local/bin/herbe'  }; -sub main +sub notify +{ +	my ($str) = @_; + +	my $pid = fork(); +	if (not $pid) { +		exec(NOTIF_PATH, $str); +	} +	return; +}; + +sub mic  {  	my $rec_vol; +	my $host; +	$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") { +			notify('[mic] muted'); +		} +		else { +			notify('[mic] 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' -			);  		}; +		notify('[mic] microphone restored');  	}  	else {  		capture {  			system(MIXER_PATH, 'rec', '0'); -			system( -				NOTIF_PATH, -				'-u', -				'low', -				'-t', -				'1750', -				'mixer-set', -				' Microphone muted' -			); +			notify('[mic] microphone muted');  		};  	} -	system('kill -68 $(pidof dwmblocks)');  	return;  } -main(); +mic();  __END__ diff --git a/.local/bin/mixer-set b/.local/bin/mixer-set index c5911bb..2f905ca 100755 --- a/.local/bin/mixer-set +++ b/.local/bin/mixer-set @@ -4,6 +4,18 @@ use strict;  use warnings;  use Term::ANSIColor;  use Capture::Tiny qw(capture); +use Sys::Hostname qw(hostname); + +sub notify +{ +	my ($str) = @_; + +	my $pid = fork(); +	if (not $pid) { +		exec('/usr/local/bin/herbe', $str); +	} +	return; +};  sub main {  	my $argc = $#ARGV + 1; @@ -21,33 +33,36 @@ 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}'"; +	}  	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', -			'-h', -			'int:value:' . $curr_vol, -			'-u', -			'low', -			'-t', -			'1000', -			'mixer-set', -			'墳 Volume' -		); -		system('kill -68 $(pidof dwmblocks)'); +		notify('[vol] ' . $curr_vol);  		exit;  	}  	elsif ($ARGV[0] eq "toggle") { @@ -58,57 +73,38 @@ sub main {  			open(my $fh, '>:encoding(UTF-8)', $tmp_file);  			print $fh $curr_vol;  			close($fh); -			capture { -				system( -					'/usr/sbin/mixer', -					'vol', -					'0' -				); -			}; -			system( -				'/usr/local/bin/notify-send', -				'-u', -				'low', -				'-t', -				'1750', -				'mixer-set', -				'婢 Volume muted' -			); -			system('kill -68 $(pidof dwmblocks)'); +			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' +					); +				}; +			} +			notify('[vol] muted');  		}  		else {  			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', -				'-h', -				'int:value:' . $curr_vol, -				'-u', -				'low', -				'-t', -				'1750', -				'mixer-set', -				$icon . ' Volume restored' -			); -			system('kill -68 $(pidof dwmblocks)'); +			notify('[vol] ' . $curr_vol);  		}  		exit;  	} diff --git a/.local/bin/nb b/.local/bin/nb deleted file mode 100755 index 117840d..0000000 --- a/.local/bin/nb +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -[ -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" -[ -f $urls_file ] && gpg -q -d $urls_file > /tmp/urls || return -[ -f $cache_file ] && gpg -q -d $cache_file > /tmp/cache.db || return -newsboat -c /tmp/cache.db -u /tmp/urls diff --git a/.local/bin/ndate b/.local/bin/ndate index 7986ae7..4ee1758 100755 --- a/.local/bin/ndate +++ b/.local/bin/ndate @@ -1,84 +1,14 @@ -#!/usr/bin/env perl -# ======================== -# =====    =============== -# ======  ================ -# ======  ================ -# ======  ====   ====   == -# ======  ===     ==  =  = -# ======  ===  =  ==     = -# =  ===  ===  =  ==  ==== -# =  ===  ===  =  ==  =  = -# ==     =====   ====   == -# ======================== -# -# 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. -# -# ndate -# Mon Apr 11 21:47:39 CEST 2022 -# Joe -# -# Script to show current date and time as notification, nice - -use strict; -use warnings; -use Capture::Tiny qw(capture); - -use constant { -	DATE_PATH		=> 'date', -	NOTIFYSEND_PATH	=> 'notify-send' -}; - -sub main -{ -	my $date; -	my $ret; - -	($date, undef, $ret) = capture { -		system(DATE_PATH, '+%a, %d %b %Y %H:%M'); -	}; -	if ($ret) { -		return 1; -	} -	$date = scalar reverse $date; -	$date =~ s/ /\n/; -	$date = scalar reverse $date; -	system( -		NOTIFYSEND_PATH, -		'-u', -		'low', -		'-t', -		'2000', -		'date', -		$date -		); -	return; -} - -main(); - -__END__ +#!/bin/sh +# ===================== +# ====  =============== +# ===================== +# ===   ===   ====   == +# ====  ==     ==  =  = +# ====  ==  =  ==     = +# ====  ==  =  ==  ==== +# ====  ==  =  ==  =  = +# =  =  ===   ====   == +# ==   ================ +# ===================== + +exec herbe "$(date '+%H:%M | %a, %d %b %Y')" & diff --git a/.local/bin/openimg b/.local/bin/openimg new file mode 100755 index 0000000..4fb0d78 --- /dev/null +++ b/.local/bin/openimg @@ -0,0 +1,7 @@ +#!/bin/sh + +for file in "$@"; do +	echo "file: $file" +done + +rotdir "$@" | command grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|tif\|ico\)\(_large\)*$" | nsxiv -abio diff --git a/.local/bin/powercmd b/.local/bin/powercmd deleted file mode 100755 index 6e6c613..0000000 --- a/.local/bin/powercmd +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -[ -z "$1" ] && echo "no arg" && exit 1 - -host="$(hostname -s)" -case $host in -	mother) icon=" " ;; -	po-rbo) icon=" " ;; -	mars) icon=" " ;; -esac - -case $1 in -	"lock")		xscreensaver-command -lock ;; -	"sleep") -		notify-send -u normal "sleep" "$icon G'night, partner!" -		sleep 1 -		xscreensaver-command -lock -		sleep 5 -		case $host in -			mother) loginctl suspend ;; -			po-rbo) systemctl suspend ;; -			mars) acpiconf -s 3 ;; -		esac -		;; -	"reboot") -		emacsclient -e '"(save-buffers-kill-emacs)"' >/dev/null 2>&1 -		notify-send -u normal reboot "$icon Rebootin' now!" -		sleep 2 -		case $host in -			mother) loginctl reboot ;; -			po-rbo) systemctl reboot ;; -			mars) shutdown -r now ;; -		esac -		;; -	"poweroff") -		emacsclient -e '"(save-buffers-kill-emacs)"' >/dev/null 2>&1 -		notify-send -u normal poweroff "$icon Farewell, partner!" -		sleep 2 -		case $host in -			mother) loginctl poweroff ;; -			po-rbo) systemctl poweroff ;; -			mars) shutdown -p now ;; -		esac -		;; -	*) -		echo "wrong arg" -		exit 1 -		;; -esac diff --git a/.local/bin/ref-newsboat b/.local/bin/ref-newsboat deleted file mode 100755 index 090ca63..0000000 --- a/.local/bin/ref-newsboat +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; -use Capture::Tiny qw(capture); - -use constant { -	NEWSBOAT_PATH		=> '/usr/local/bin/newsboat', -	NOTIFY_SEND_PATH	=> '/usr/local/bin/notify-send' -}; - -sub main -{ -	my $stdout; -	if (system( -		NEWSBOAT_PATH, -		'-x', -		'reload' -	) != 0) { -		exit 1; -	} -	($stdout, undef, undef) = capture { -		system( -			NEWSBOAT_PATH, -			'-x', -			'print-unread' -		); -	}; -	$stdout =~ s/\s.+//; -	chomp $stdout; -	if ($stdout != 0) { -		system( -			NOTIFY_SEND_PATH, -			'-u', -			'low', -			'newsboat', -			'  ' . $stdout . ' new articles' -		); -	} -	exit 0; -} - -main(); - -__END__ diff --git a/.local/bin/rkb b/.local/bin/rkb deleted file mode 100755 index ff870d3..0000000 --- a/.local/bin/rkb +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -notify-send -u low -t 2000 'kb' '  Restored Esc/Tab' -setxkbmap -option -setxkbmap -layout us -variant intl diff --git a/.local/bin/rotdir b/.local/bin/rotdir index 013ef86..f2498ce 100755 --- a/.local/bin/rotdir +++ b/.local/bin/rotdir @@ -11,4 +11,4 @@  [ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1  base="$(basename "$1")" -exa "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }' +command ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }' diff --git a/.local/bin/scr1 b/.local/bin/scr1 new file mode 100755 index 0000000..d4e5c40 --- /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 + +feh --no-fehbg --image-bg '#1d2021' --no-xinerama --bg-fill "$HOME"/pics/wp.jpg diff --git a/.local/bin/scr2 b/.local/bin/scr2 new file mode 100755 index 0000000..7ebde1f --- /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 + +feh --no-fehbg --image-bg '#1d2021' --no-xinerama --bg-fill "$HOME"/pics/wp.jpg diff --git a/.local/bin/scr3 b/.local/bin/scr3 new file mode 100755 index 0000000..e679d17 --- /dev/null +++ b/.local/bin/scr3 @@ -0,0 +1,13 @@ +#!/bin/sh + +xrandr \ +	--output HDMI-0 --mode 1920x1080 --rate 60 --pos 0x0 --rotate normal \ +	--output DP-0 --off \ +	--output DP-1 --off \ +	--output DP-2 --mode 2560x1440 --rate 144 --pos 4480x0 --rotate normal \ +	--output DP-3 --off \ +	--output DP-4 --primary --mode 2560x1440 --rate 144 --pos 1920x0 --rotate normal \ +	--output DP-5 --off + + +feh --no-fehbg --image-bg '#1d2021' --no-xinerama --bg-fill "$HOME"/pics/wp.jpg 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..fa0d255 100755 --- a/.local/bin/setwp +++ b/.local/bin/setwp @@ -37,70 +37,67 @@ 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 -	); -	return 0; -} -sub notify -{ -	system( -		'notify-send', -		'-u', -		'low', -		'-t', -		'2000', -		'setwp', -		'  wp set' -	); -	return; -} - -sub notify_error -{ -	system( -		'notify-send', -		'-u', -		'critical', -		'-t', -		'4000', -		'setwp', -		'  Wallpaper does not exist or is not a valid file' -	); -	return; +	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;  }  sub main  {  	my $wp;  	my $ret; +	my $arg; -	if (@ARGV != 0 && -f $ARGV[0]) { -		$ret = set_wp($ARGV[0]); +	$arg = 0; +	if (@ARGV != 0 && $ARGV[0] eq '-nw') { +		$arg = 1; +	} +	if (@ARGV != 0 && -f $ARGV[$arg]) { +		$ret = set_wp($ARGV[$arg]);  	} -	elsif (@ARGV != 0 && -d $ARGV[0]) { -		$wp = choose_wp(get_pool_files($ARGV[0])); +	elsif (@ARGV != 0 && -d $ARGV[$arg]) { +		$wp = choose_wp(get_pool_files($ARGV[$arg]));  		$ret = set_wp($wp);  	}  	else {  		$wp = choose_wp(get_pool_files(WP_POOL));  		$ret = set_wp($wp);  	} -	if (@ARGV == 0 || (@ARGV != 0 && $ARGV[0] ne "-nw")) { -		notify() if ($ret == 0); -		notify_error() if ($ret != 0); +	if (@ARGV == 0 || (@ARGV != 0 && $ARGV[0] ne '-nw')) { +		my $arg = fork(); +		if (not $arg) { +			exec('herbe', 'wp set') if ($ret == 0); +			exec('herbe', 'wp is not a valid file') if ($ret != 0); +		}  	}  	return;  } diff --git a/.local/bin/sf b/.local/bin/sf new file mode 100755 index 0000000..89c9848 --- /dev/null +++ b/.local/bin/sf @@ -0,0 +1,3 @@ +#!/bin/sh + +sfeed_curses $XDG_DATA_HOME/sfeed/feeds/* diff --git a/.local/bin/startemacs b/.local/bin/startemacs deleted file mode 100755 index d0034d6..0000000 --- a/.local/bin/startemacs +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - - -if ! pgrep emacs >/dev/null; then -	emacs --daemon >/dev/null 2>&1 -	exec notify-send -u low -t 2000 'emacs' '  Emacs daemonized' -fi diff --git a/.local/bin/status/sb-battery b/.local/bin/status/sb-battery deleted file mode 100755 index 2fe3ce5..0000000 --- a/.local/bin/status/sb-battery +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -case $(hostname -s) in -	mother) exit ;; -	po-rbo) -		printf "^c#fabd2f^" -		charge=$(cat /sys/class/power_supply/BAT0/capacity) -		case "$(cat /sys/class/power_supply/BAT0/status)" in -			"Charging"|"Not charging") printf " " ;; -			"Full") printf " "; return ;; -		esac -		;; -	mars) -		echo -n "^c#fabd2f^" -		charge=$(apm -l) -		[ "$(apm -b)" -eq 3 ] && printf " " -		;; -esac - -case $(echo "$charge" / 20 | bc) in -	"0") printf " " ;; -	"1") printf " " ;; -	"2") printf " " ;; -	"3") printf " " ;; -	"4") -		[ "$charge" -gt 98 ] && return -		printf " " -		;; -	"5") -		[ "$(cat /sys/class/power_supply/BAT0/status)" = "Charging" ] && return -		printf "" -		;; -esac diff --git a/.local/bin/status/sb-clock b/.local/bin/status/sb-clock deleted file mode 100755 index cf315f0..0000000 --- a/.local/bin/status/sb-clock +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -echo -n "^d^" -clock=$(date '+%I') - -case "$clock" in -	"00") icon="" ;; -	"01") icon="" ;; -	"02") icon="" ;; -	"03") icon="" ;; -	"04") icon="" ;; -	"05") icon="" ;; -	"06") icon="" ;; -	"07") icon="" ;; -	"08") icon="" ;; -	"09") icon="" ;; -	"10") icon="" ;; -	"11") icon="" ;; -	"12") icon="" ;; -esac - -# case $BLOCK_BUTTON in -# 	1) notify-send -u low "This Month" "$(cal | sed "s/..7m/<b><span color=\"red\">/;s|..27m|</span></b>|")" && notify-send "Appointments" "$(calcurse -d3)" ;; -# 	2) bsdsetsid -f "$TERMINAL" -e calcurse -C $XDG_CONFIG_HOME/calcurse -D $XDG_DATA_HOME/calcurse ;; -# 	3) notify-send -u low "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\` - Middle click opens calcurse if installed" ;; -# 	6) "$TERMINAL" -e "$EDITOR" "$0" ;; -# esac - -date "+$icon %H:%M" diff --git a/.local/bin/status/sb-cpu b/.local/bin/status/sb-cpu deleted file mode 100755 index fe3712a..0000000 --- a/.local/bin/status/sb-cpu +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# ncpu_file="/tmp/ncpu" -# if [ -f $ncpu_file ]; then -# 	ncpu=$(cat $ncpu_file) -# else -# 	ncpu=$(sysctl -n hw.ncpu | tee $ncpu_file) -# fi - -printf "^c#8ec07c^ " -# for i in $(top -P -d 2 -s 0.2 | grep '^CPU' | tail -n$ncpu | sed '{s/% idle$//;s/.*[[:blank:]]//;s/\..*//;s/^/100 - /;}' | bc); do -case $(hostname -s) in -	mother|po-rbo) -		stats=$(uptime | head -n1) -		top -b -d 0.1 -n 1 | grep "Cpu(s)" | \ -           sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | \ -           awk '{print int(100 - $1)"%"}' -		exit -		;; -	mars) -		stats=$(top -d 2 -s 0.2 | grep -E 'load averages:|^CPU') -		printf "%s " "$(echo "$stats" | sed '{1,2d;4d;s/.*averages: *//;s/,.*//;}')" -		;; -esac - -case $(echo "$stats" | sed '{1,3d;s/% idle$//;s/.*[[:blank:]]//;s/\..*//;s/^/(100 - /;s/$/) \/ 12\.5/;}' | bc) in -		"0") printf "[        ]\n" ;; -		"1") printf "[=       ]\n" ;; -		"2") printf "[==      ]\n" ;; -		"3") printf "[===     ]\n" ;; -		"4") printf "[====    ]\n" ;; -		"5") printf "[=====   ]\n" ;; -		"6") printf "[======  ]\n" ;; -		"7") printf "[======= ]\n" ;; -		"8") printf "[========]\n" ;; -esac - diff --git a/.local/bin/status/sb-disk b/.local/bin/status/sb-disk deleted file mode 100755 index 527a1d1..0000000 --- a/.local/bin/status/sb-disk +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -echo -n "^c#d3869b^ " -df=$(df -h -T | grep '/$') -if echo "$df" | grep zfs >/dev/null 2>&1; then -	zpool list $(echo $df | sed 's/\/.*//') | tail -n1 | awk '{print $3"/"$2}' -else -	echo "$df" | awk '{print $6}' -fi diff --git a/.local/bin/status/sb-forecast b/.local/bin/status/sb-forecast deleted file mode 100755 index e3c8f0d..0000000 --- a/.local/bin/status/sb-forecast +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# weatherreport="/tmp/weatherreport" -# weatherglyph="/tmp/weatherglyph" -# moonglyph="/tmp/moonglyph" - -weatherreport=$(curl -sf "wttr.in/Lyon" 2>&1 || exit 1) # >$weatherreport || (rm -f $weatherreport && exit 1) -weatherglyph=$(curl -sf "wttr.in/Lyon?format=%c" 2>&1 || exit 1) # >$weatherglyph || exit 1 -moonglyph=$(curl -sf "wttr.in/?format=%m" 2>&1 || exit 1) # >$moonglyph || exit 1 - -printf "^c#83a598^%s%s" \ -	"$(echo "$weatherglyph")" \ -	"$(echo "$weatherreport" | sed '16q;d' | grep -wo "[0-9]*%" | sort -rn | sed "s/^/ /g;1q" | tr -d '\n')" - -echo "$weatherreport" | sed '13q;d' | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | -	sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | -	awk -v moon="$(echo "$moonglyph")" '{print "  " $1 "/" $2 "°C " moon}' diff --git a/.local/bin/status/sb-mailbox b/.local/bin/status/sb-mailbox deleted file mode 100755 index f7a3786..0000000 --- a/.local/bin/status/sb-mailbox +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -# Displays number of unread mail and an loading icon if updating. -# When clicked, brings up `neomutt`. - -case $BLOCK_BUTTON in -	1) setsid -f "$TERMINAL" -e neomutt ;; -	2) setsid -f mw -Y >/dev/null ;; -	3) notify-send "📬 Mail module" "\- Shows unread mail -- Shows 🔃 if syncing mail -- Left click opens neomutt -- Middle click syncs mail" ;; -	6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -mb_a="$(ls "${MAIL:-/var/mail/jozan}"/gmail_br/INBOX/new/ | wc -l 2>/dev/null)" -mb_b="$(ls "${MAIL:-/var/mail/jozan}"/gmail_oon/INBOX/new/ | wc -l 2>/dev/null)" -mb_c="$(ls "${MAIL:-/var/mail/jozan}"/gmail_tos/INBOX/new/ | wc -l 2>/dev/null)" - -sync=0 -if pidof mbsync >/dev/null 2>&1; then -	sync=1 -fi - -case "$sync" in -	0) ([ "$mb_a" -gt 0 ] || [ "$mb_b" -gt 0 ] || [ "$mb_c" -gt 0 ] || [ "$mb_d" -gt 0 ]) && echo -n " " ;; -	1) echo -n " " ;; -	*) ;; -esac	 - -if [ "$mb_a" -gt 0 ]; then -	echo -n "br:" $mb_a -fi - -if [ "$mb_a" -gt 0 ] && [ "$mb_b" -gt 0 ]; then -	echo -n " - " -fi - -if [ "$mb_b" -gt 0 ]; then -	echo -n "oon:" $mb_b -fi - -if [ "$mb_b" -gt 0 ] && [ "$mb_c" -gt 0 ]; then -	echo -n " - " -elif [ "$mb_a" -gt 0 ] && [ "$mb_c" -gt 0 ]; then -	echo -n " - " -fi - -if [ "$mb_c" -gt 0 ]; then -	echo -n "tos:" $mb_c -fi diff --git a/.local/bin/status/sb-memory b/.local/bin/status/sb-memory deleted file mode 100755 index 0786b85..0000000 --- a/.local/bin/status/sb-memory +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -echo -n "^c#b8bb26^ " -case $(hostname -s) in -	mother|po-rbo) -		free | sed -n '2p' | awk '{print int(100 - ($7 * 100 / $2))"%"}' -		;; -	mars) -		sysctl -n hw.physmem \ -			hw.pagesize \ -			vm.stats.vm.v_inactive_count \ -			vm.stats.vm.v_free_count \ -			vm.stats.vm.v_cache_count | xargs | awk '{printf ("%2.2fG/%2.2fG\n", ($1 / (1024 ^ 3)) - (($3 + $4 + $5) * $2 / (1024 ^ 3)), ($1 / (1024 ^ 3)))}' -					;; -esac diff --git a/.local/bin/status/sb-mpd b/.local/bin/status/sb-mpd deleted file mode 100755 index 21bf2c7..0000000 --- a/.local/bin/status/sb-mpd +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -return -mp=$(mpc status) -icon=$(echo "$mp" | sed -n 2p | sed -E 's/(^|\])[^[]*($|\[)//g') -case $icon in -	"playing") icon="契" ;; -	"paused")  icon="" ;; -	*)         return   ;; -esac -printf "%s %s" "$icon" "$(echo "$mp" | head -n1)" diff --git a/.local/bin/status/sb-net b/.local/bin/status/sb-net deleted file mode 100755 index 50fdc0a..0000000 --- a/.local/bin/status/sb-net +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -echo -n "^c#a89984^" -case $(hostname -s) in -	mother|po-rbo) ping="ping -c1 -w1 9.9.9.9" ;; -	mars)          ping="ping -c1 -t1 9.9.9.9" ;; -esac -ifc=$(ifconfig) -if echo "$ifc" | grep -E '^wg' >/dev/null 2>&1; then -	echo -n "  " -fi -if echo "${ifc}" | grep -E '^zt' >/dev/null 2>&1; then -	echo -n "  " -fi -if echo "${ifc}" | grep -E '^tun|^vpn' >/dev/null 2>&1; then -	echo -n "  " -fi -if ! $ping >/dev/null 2>&1; then -	echo "" -	exit -fi - -echo "" diff --git a/.local/bin/status/sb-os b/.local/bin/status/sb-os deleted file mode 100755 index 304aa19..0000000 --- a/.local/bin/status/sb-os +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -case $(hostname -s) in -	mother) os="^c#83a598^" ;; -	po-rbo) os="^c#8ec07c^" ;; -	mars)   os="^c#fb4934^" ;; -esac - -echo "$os " diff --git a/.local/bin/status/sb-temp b/.local/bin/status/sb-temp deleted file mode 100755 index dfa17c7..0000000 --- a/.local/bin/status/sb-temp +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -case $(hostname -s) in -	mother) ;; -	po-rbo) cat /sys/class/hwmon/hwmon5/temp1_input | awk '{printf ("^c#fb4934^ %3.1f°C", ($1 / 1000))}' ;; -	mars) echo -n "" $(sysctl -n dev.cpu.0.temperature | cut -d '.' -f1)"°C" ;; -esac diff --git a/.local/bin/status/sb-tools b/.local/bin/status/sb-tools deleted file mode 100755 index 9c7484c..0000000 --- a/.local/bin/status/sb-tools +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -if pidof emacs-28.2 >/dev/null 2>&1; then -	echo -n "  " -fi -if pgrep gpg-agent >/dev/null 2>&1; then -	echo -n " " -else -	echo -n " " -fi diff --git a/.local/bin/status/sb-updatempd b/.local/bin/status/sb-updatempd deleted file mode 100755 index 878052a..0000000 --- a/.local/bin/status/sb-updatempd +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -while true; do -	mpc idle >/dev/null 2>&1 -	kill -75 $(pidof dwmblocks) >/dev/null 2>&1 -done diff --git a/.local/bin/status/sb-volume b/.local/bin/status/sb-volume deleted file mode 100755 index bc1ca97..0000000 --- a/.local/bin/status/sb-volume +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -[ $(hostname -s) = "mars" ] || return - -vol="$(mixer vol | awk '{print $7}' | cut -d ':' -f1)" - -if [ "$vol" -gt "0" ]; then -	icon="" -else -	icon="婢" -fi - -mic="$(mixer rec | awk '{print $7}' | cut -d ':' -f1)" - -if [ "$mic" -gt "0" ]; then -	micon="" -else -	micon="" -fi - -echo -n "$micon  $icon " - -case $(echo $vol / 12.5 | bc) in -	"0") printf "[        ]";; -	"1") printf "[=       ]";; -	"2") printf "[==      ]";; -	"3") printf "[===     ]";; -	"4") printf "[====    ]";; -	"5") printf "[=====   ]";; -	"6") printf "[======  ]";; -	"7") printf "[======= ]";; -	"8") printf "[========]";; -esac diff --git a/.local/bin/stopemacs b/.local/bin/stopemacs deleted file mode 100755 index d31541c..0000000 --- a/.local/bin/stopemacs +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -emacsclient -e '(save-buffers-kill-terminal)' -exec notify-send  -u low -t 2000 'emacs' '  Emacs daemon stoped' diff --git a/.local/bin/swsnd b/.local/bin/swsnd index d64a034..60feb1a 100755 --- a/.local/bin/swsnd +++ b/.local/bin/swsnd @@ -9,10 +9,7 @@ else if (`$cmd | rev | cut -d ' ' -f 1` == 0) then  else  	$cmd=0 >&/dev/null  endif -exec notify-send \ -	-u low \ -	-t 2000 \ -	'swsnd' \ -	"Switched to `grep default /dev/sndstat | \ +exec herbe \ +		 "Switched to `grep default /dev/sndstat | \  		sed -e 's/.*<\(.*\)>.*/\1/' | \  		sed -e 's/.*(\(.*\)).*/\1/'`" 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 diff --git a/.local/bin/tsm-done.sh b/.local/bin/tsm-done.sh deleted file mode 100755 index 1bea50b..0000000 --- a/.local/bin/tsm-done.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -notify-send \ -	-u normal \ -	-t 10000 \ -	'Transmission' \ -	'  Torrent <b>'"$TR_TORRENT_NAME"'</b> downloaded to <b>'"$TR_TORRENT_DIR"'</b>' diff --git a/.local/bin/vps b/.local/bin/vps index e2b43aa..128ebe0 100755 --- a/.local/bin/vps +++ b/.local/bin/vps @@ -1,18 +1,15 @@  #!/bin/sh -serv_addr="10.10.10.6" -serv_port="10022" +serv_addr="10.0.0.2" +serv_port="22"  # joe-www -rsync -e "ssh -p$serv_port" -avh --no-o --no-g --delete-after \ +rsync -e "ssh -p$serv_port" -avh --progress --no-o --no-g --delete-after \  	  --exclude '.*' \  	  --exclude 'README.org' \  	  --exclude 'LICENSE' \  	  --exclude 'asm-example.cgi' \  	  --exclude 'files/' \ -	  --exclude 'caco' \ -	  --exclude 'sad' \ -	  --exclude 'bon_concert' \  	  "$HOME"/dev/web/joe-www/ \  	  root@$serv_addr:/var/jail/www/var/www/joe/  # gitjoe-cgit | 
