diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-18 15:45:02 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-18 15:45:02 +0200 |
commit | 054955db38bb571c294b5d86c78639e3b1091031 (patch) | |
tree | 6dd4b42405c4693cd35ad6b7d07b163cfcb584f5 /.local | |
parent | Added emacs config (diff) | |
download | dotfiles-bsd-054955db38bb571c294b5d86c78639e3b1091031.tar.gz dotfiles-bsd-054955db38bb571c294b5d86c78639e3b1091031.tar.bz2 dotfiles-bsd-054955db38bb571c294b5d86c78639e3b1091031.tar.xz dotfiles-bsd-054955db38bb571c294b5d86c78639e3b1091031.tar.zst dotfiles-bsd-054955db38bb571c294b5d86c78639e3b1091031.zip |
Added scripts
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/brb | 11 | ||||
-rwxr-xr-x | .local/bin/dualscreen | 13 | ||||
-rwxr-xr-x | .local/bin/gotosleep | 4 | ||||
-rwxr-xr-x | .local/bin/greptemp.sh | 6 | ||||
-rwxr-xr-x | .local/bin/install-port | 162 | ||||
-rwxr-xr-x | .local/bin/mainscreen | 12 | ||||
-rwxr-xr-x | .local/bin/maze | 4 | ||||
-rwxr-xr-x | .local/bin/mixer-set | 83 | ||||
-rwxr-xr-x | .local/bin/modebrb | 8 | ||||
-rwxr-xr-x | .local/bin/modestartsoon | 8 | ||||
-rwxr-xr-x | .local/bin/startsoon | 11 | ||||
-rwxr-xr-x | .local/bin/swscreen | 5 | ||||
-rwxr-xr-x | .local/bin/sync-elfeed.sh | 7 | ||||
-rwxr-xr-x | .local/bin/sync-todo.sh | 7 | ||||
-rwxr-xr-x | .local/bin/triplescreen | 27 | ||||
-rwxr-xr-x | .local/bin/webview.sh | 18 |
16 files changed, 386 insertions, 0 deletions
diff --git a/.local/bin/brb b/.local/bin/brb new file mode 100755 index 0000000..bf46280 --- /dev/null +++ b/.local/bin/brb @@ -0,0 +1,11 @@ +#!/usr/local/bin/dash + +while true; do + clear + # figlet -s -L -c -t "Joe will be right back" | lolcat -F 0.05 + figlet -s -L -c -t "Joe will be right back" + echo + # figlet -s -L -c -t "please stand by..." | lolcat -F 0.05 + figlet -s -L -c -t "please stand by..." + sleep 5 +done diff --git a/.local/bin/dualscreen b/.local/bin/dualscreen new file mode 100755 index 0000000..1e54bd9 --- /dev/null +++ b/.local/bin/dualscreen @@ -0,0 +1,13 @@ +#!/bin/sh + +xrandr --output VGA1 --off +xrandr --output HDMI1 --off +xrandr --output DP1 --primary --mode 1920x1080 --pos 0x0 --rotate normal +xrandr --output LVDS1 --mode 1366x768 --pos 1920x312 --rotate normal +xrandr --output HDMI2 --off +xrandr --output HDMI3 --off +xrandr --output DP2 --off +xrandr --output DP3 --off + +bspc monitor DP1 -d 01 02 03 04 05 06 07 +bspc monitor LVDS1 -d 08 09 10 11 12 diff --git a/.local/bin/gotosleep b/.local/bin/gotosleep new file mode 100755 index 0000000..a11b3c4 --- /dev/null +++ b/.local/bin/gotosleep @@ -0,0 +1,4 @@ +#!/usr/local/bin/dash + +slock & +sudo acpiconf -s 3 diff --git a/.local/bin/greptemp.sh b/.local/bin/greptemp.sh new file mode 100755 index 0000000..ab397dc --- /dev/null +++ b/.local/bin/greptemp.sh @@ -0,0 +1,6 @@ +#!/usr/local/bin/dash + +while true; do + sysctl dev.cpu | grep temperature + sleep 3 +done diff --git a/.local/bin/install-port b/.local/bin/install-port new file mode 100755 index 0000000..4c76620 --- /dev/null +++ b/.local/bin/install-port @@ -0,0 +1,162 @@ +#!/usr/local/bin/perl -w + +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/dash', + '-c', + '/usr/local/bin/sudo /usr/sbin/pkg update') != 0) { + exit; + } + if (system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/sudo /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 ($upgrd_nbr == 1) { + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Initiating ' . $upgrd_nbr . ' port upgrade" & >/dev/null 2>&1'); + } + else { + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Initiating ' . $upgrd_nbr . ' ports upgrade" & >/dev/null 2>&1'); + } + if (system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/sudo /usr/local/sbin/portupgrade -a') == 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'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Success: $upnbr ports upgrade installed successfully" & >/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'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Failure: not all ports were upgraded - $diffnbr installed - $failednbr failed" & >/dev/null 2>&1'); + } + exit; +} + +sub configport { + my $port = $_[0]; + my $port_basename = $_[1]; + if (system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/sudo /usr/bin/make config-recursive && /usr/local/bin/sudo /usr/bin/make config-recursive && /usr/local/bin/sudo /usr/bin/make config-recursive') == 0) { + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send "Configuration success!" "Ports config - ' . $port . ' - configured successfully" >/dev/null 2>&1'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Success: ' . $port_basename . ' configured successfully. Initiating compilation." & >/dev/null 2>&1'); + } + else { + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send -u critical -t 10000 "Configuration failure!" "Ports config - ' . $port . ' - failed to configure" >/dev/null 2>&1'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Failure: failed to configure ' . $port_basename . '" & >/dev/null 2>&1'); + } +} + +sub installport { + my $port = $_[0]; + my $port_basename = $_[1]; + if (system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/sudo /usr/bin/make install clean') == 0) { + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send "Compilation success!" "Ports - ' . $port . ' - installed successfully" >/dev/null 2>&1'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Success: ' . $port_basename . ' installed successfully" & >/dev/null 2>&1'); + } + else { + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send -u critical -t 10000 "Compilation failure!" "Ports - ' . $port . ' - failed to install" >/dev/null 2>&1'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/espeak "Failure: failed to install ' . $port_basename . '" & >/dev/null 2>&1'); + } +} + +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/mainscreen b/.local/bin/mainscreen new file mode 100755 index 0000000..6164bf8 --- /dev/null +++ b/.local/bin/mainscreen @@ -0,0 +1,12 @@ +#!/bin/sh + +xrandr --output LVDS1 --primary --mode 1366x768 --pos 0x0 --rotate normal +xrandr --output VGA1 --off +xrandr --output HDMI1 --off +xrandr --output DP1 --off +xrandr --output HDMI2 --off +xrandr --output HDMI3 --off +xrandr --output DP2 --off +xrandr --output DP3 --off + +bspc monitor LVDS1 -d 01 02 03 04 05 06 07 08 09 10 11 12 diff --git a/.local/bin/maze b/.local/bin/maze new file mode 100755 index 0000000..132714f --- /dev/null +++ b/.local/bin/maze @@ -0,0 +1,4 @@ +#!/usr/local/bin/bash + +cols=$(tput cols) +grep -ao "[/\\]" /dev/urandom | sed -e 's,\\,╲,' -e 's,/,╱,'| tr -d \\n | while read -r -n"$cols" input; do echo "$input"; done | lolcat -F 0.01 diff --git a/.local/bin/mixer-set b/.local/bin/mixer-set new file mode 100755 index 0000000..e74beeb --- /dev/null +++ b/.local/bin/mixer-set @@ -0,0 +1,83 @@ +#!/usr/local/bin/perl -w + +use strict; +use warnings; +use Term::ANSIColor; + +sub main { + my $argc = $#ARGV + 1; + if ($argc == 0) { + print "Argument needed - [" + . colored("lower", 'bold') + . " - " + . colored("raise", 'bold') + . " - " + . colored("toggle", 'bold') + . "]\n"; + exit 1; + } + elsif ($argc > 1) { + print "Too many arguments, only one needed\n"; + exit 2; + } + my $curr_vol = 0; + my $curr_vol_cmd = "/usr/sbin/mixer vol | /usr/bin/awk -F ':' '{print \$2}'"; + if ($ARGV[0] eq "lower") { + system('/usr/local/bin/dash', + '-c', + '/usr/sbin/mixer vol -5 >/dev/null 2>&1'); + $curr_vol = `$curr_vol_cmd`; + chomp $curr_vol; + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send -u low -t 400 "Volume lowered - ' . $curr_vol . '%"'); + exit; + } + elsif ($ARGV[0] eq "raise") { + system('/usr/local/bin/dash', + '-c', + '/usr/sbin/mixer vol +5 >/dev/null 2>&1'); + $curr_vol = `$curr_vol_cmd`; + chomp $curr_vol; + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send -u low -t 400 "Volume raised - ' . $curr_vol . '%"'); + exit; + } + elsif ($ARGV[0] eq "toggle") { + my $tmp_file = '/tmp/mixervol'; + $curr_vol = `$curr_vol_cmd`; + chomp $curr_vol; + if ($curr_vol > 0) { + open(my $fh, '>:encoding(UTF-8)', $tmp_file); + print $fh $curr_vol; + close($fh); + system('/usr/local/bin/dash', + '-c', + '/usr/sbin/mixer vol 0 >/dev/null 2>&1'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send -u low -t 1750 "Volume muted"'); + } + else { + open(my $fh, '<:encoding(UTF-8)', $tmp_file); + $curr_vol = <$fh>; + close($fh); + system('/usr/local/bin/dash', + '-c', + '/usr/sbin/mixer vol ' . $curr_vol . ' >/dev/null 2>&1'); + system('/usr/local/bin/dash', + '-c', + '/usr/local/bin/notify-send -u low -t 1750 "Volume restored - ' . $curr_vol . '%"'); + } + exit; + } + else { + print "Unrecognized argument: " . $ARGV[0] . "\n"; + } + exit; +} + +main(); + +__END__ diff --git a/.local/bin/modebrb b/.local/bin/modebrb new file mode 100755 index 0000000..552fd73 --- /dev/null +++ b/.local/bin/modebrb @@ -0,0 +1,8 @@ +#!/usr/local/bin/dash + +st -e '/home/jozan/.local/bin/brb' & +sleep 0.5 +st -e '/home/jozan/.local/bin/maze' & +sleep 2 +bspc node -z top 0 -260 +exit diff --git a/.local/bin/modestartsoon b/.local/bin/modestartsoon new file mode 100755 index 0000000..638d85f --- /dev/null +++ b/.local/bin/modestartsoon @@ -0,0 +1,8 @@ +#!/usr/local/bin/dash + +st -e '/home/jozan/.local/bin/startsoon' & +sleep 0.5 +st -e '/home/jozan/.local/bin/maze' & +sleep 2 +bspc node -z top 0 -260 +exit diff --git a/.local/bin/startsoon b/.local/bin/startsoon new file mode 100755 index 0000000..599428f --- /dev/null +++ b/.local/bin/startsoon @@ -0,0 +1,11 @@ +#!/usr/local/bin/dash + +while true; do + clear + # figlet -s -L -c -t "Stream starting soon" | lolcat -F 0.05 + figlet -s -L -c -t "Stream starting soon" + echo + # figlet -s -L -c -t "take a coffee!" | lolcat -F 0.05 + figlet -s -L -c -t "take a coffee!" + sleep 5 +done diff --git a/.local/bin/swscreen b/.local/bin/swscreen new file mode 100755 index 0000000..f0ae3e8 --- /dev/null +++ b/.local/bin/swscreen @@ -0,0 +1,5 @@ +#!/usr/local/bin/dash + +xrandr --output LVDS1 --off --output VGA1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI1 --off --output DP1 --off --output HDMI2 --off --output HDMI3 --off --output DP2 --off --output DP3 --off + +bspc monitor VGA1 -d 01 02 03 04 05 06 07 08 09 10 diff --git a/.local/bin/sync-elfeed.sh b/.local/bin/sync-elfeed.sh new file mode 100755 index 0000000..c39257a --- /dev/null +++ b/.local/bin/sync-elfeed.sh @@ -0,0 +1,7 @@ +#!/usr/local/bin/dash + +date=$(date) +git -C ~/.elfeed add . >/dev/null 2>&1 +git -C ~/.elfeed commit -m "$date" >/dev/null 2>&1 || exit 1 +git -C ~/.elfeed push origin master >/dev/null 2>&1 +exit diff --git a/.local/bin/sync-todo.sh b/.local/bin/sync-todo.sh new file mode 100755 index 0000000..21001d3 --- /dev/null +++ b/.local/bin/sync-todo.sh @@ -0,0 +1,7 @@ +#!/usr/local/bin/dash + +date=$(date) +git -C /usr/home/jozan/.emacs.d/org/todo add . >/dev/null 2>&1 +git -C /usr/home/jozan/.emacs.d/org/todo commit -m "$date" >/dev/null 2>&1 || exit 1 +git -C /usr/home/jozan/.emacs.d/org/todo push origin master >/dev/null 2>&1 +exit diff --git a/.local/bin/triplescreen b/.local/bin/triplescreen new file mode 100755 index 0000000..39021d2 --- /dev/null +++ b/.local/bin/triplescreen @@ -0,0 +1,27 @@ +#!/bin/sh + +# Small screen on the left +# xrandr --output LVDS1 --off +# xrandr --output VGA1 --mode 1440x900 --pos 0x324 --rotate normal +# xrandr --output HDMI1 --off +# xrandr --output DP1 --primary --mode 1920x1080 --pos 1440x0 --rotate normal +# xrandr --output HDMI2 --off +# xrandr --output HDMI3 --off +# xrandr --output DP2 --off +# xrandr --output DP3 --off + +# bspc monitor VGA1 -d 01 02 03 04 09 10 11 12 +# bspc monitor DP1 -d 05 06 07 08 + +# Small screen on the right +xrandr --output LVDS1 --off +xrandr --output HDMI1 --off +xrandr --output DP1 --primary --mode 1920x1080 --pos 0x0 --rotate normal +xrandr --output VGA1 --mode 1440x900 --pos 1920x226 --rotate normal +xrandr --output HDMI2 --off +xrandr --output HDMI3 --off +xrandr --output DP2 --off +xrandr --output DP3 --off + +bspc monitor VGA1 -d 08 09 10 11 12 +bspc monitor DP1 -d 01 02 03 04 05 06 07 diff --git a/.local/bin/webview.sh b/.local/bin/webview.sh new file mode 100755 index 0000000..6975853 --- /dev/null +++ b/.local/bin/webview.sh @@ -0,0 +1,18 @@ +#!/usr/local/bin/dash + +ext="${1##*.}" +mpvFiles="mkv mp4 gif" +sxivFiles="png jpg jpeg jpe" +wgetFiles="flac mp3 mp3?source=feed opus pdf doc docx" + +cd ~/Downloads || exit + +if echo "$sxivFiles" | grep -w "$ext" > /dev/null; then + nohup sxiv "$1" > /dev/null & +elif echo "$mpvFiles" | grep -w "$ext" > /dev/null; then + nohup mpv --loop --quiet "$1" > /dev/null & +elif echo "$wgetFiles" | grep -w "$ext" > /dev/null; then + nohup st -e wget "$1" > /dev/null & +else + nohup qutebrowser "$1" > /dev/null & +fi |