aboutsummaryrefslogtreecommitdiff
path: root/bin/.local
diff options
context:
space:
mode:
authorBardofSprites <[email protected]>2025-07-17 10:25:05 -0400
committerBardofSprites <[email protected]>2025-07-17 10:25:05 -0400
commit87f6f34b5e6df17811b6b76ea67e457e84f7a84e (patch)
treee25f1c870038a6b342374acf64c0f54399d85d5d /bin/.local
parentb75dd69104999a4a450c6c5f575f38f2528be79d (diff)
small script changes
Diffstat (limited to 'bin/.local')
-rwxr-xr-xbin/.local/bin/scripts/acme-launch3
-rwxr-xr-xbin/.local/bin/scripts/crosswords18
-rwxr-xr-xbin/.local/bin/scripts/nsxiv-pipe24
-rwxr-xr-xbin/.local/bin/scripts/perl/convert-color21
-rwxr-xr-xbin/.local/bin/scripts/perl/forecast71
-rwxr-xr-xbin/.local/bin/scripts/perl/sdownload28
-rwxr-xr-xbin/.local/bin/scripts/smart-launcher39
-rwxr-xr-xbin/.local/bin/scripts/tmux-sessionizer2
8 files changed, 205 insertions, 1 deletions
diff --git a/bin/.local/bin/scripts/acme-launch b/bin/.local/bin/scripts/acme-launch
new file mode 100755
index 0000000..6371a15
--- /dev/null
+++ b/bin/.local/bin/scripts/acme-launch
@@ -0,0 +1,3 @@
+#!/bin/bash
+fontsrv &
+acme -f /mnt/font/'GoMonoNFM'/12a/font &
diff --git a/bin/.local/bin/scripts/crosswords b/bin/.local/bin/scripts/crosswords
new file mode 100755
index 0000000..e382cdd
--- /dev/null
+++ b/bin/.local/bin/scripts/crosswords
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+CROSSWORDS_DIR=~/Boox/Documents/crosswords
+
+wget https://www.onlinecrosswords.net/printable-daily-crosswords-{1,2,3,4,5,6,7}.pdf
+
+# mkdir $CROSSWORDS_DIR
+mv printable-daily-crosswords* $CROSSWORDS_DIR
+mv $CROSSWORDS_DIR/printable-daily-crosswords-1.pdf $CROSSWORDS_DIR/puzz#1_$(date +%Y-%m-%d).pdf
+mv $CROSSWORDS_DIR/printable-daily-crosswords-2.pdf $CROSSWORDS_DIR/puzz#2_$(date +%Y-%m-%d).pdf
+mv $CROSSWORDS_DIR/printable-daily-crosswords-3.pdf $CROSSWORDS_DIR/puzz#3_$(date +%Y-%m-%d).pdf
+mv $CROSSWORDS_DIR/printable-daily-crosswords-4.pdf $CROSSWORDS_DIR/puzz#4_$(date +%Y-%m-%d).pdf
+mv $CROSSWORDS_DIR/printable-daily-crosswords-5.pdf $CROSSWORDS_DIR/puzz#5_$(date +%Y-%m-%d).pdf
+mv $CROSSWORDS_DIR/printable-daily-crosswords-6.pdf $CROSSWORDS_DIR/puzz#6_$(date +%Y-%m-%d).pdf
+mv $CROSSWORDS_DIR/printable-daily-crosswords-7.pdf $CROSSWORDS_DIR/puzz#7_$(date +%Y-%m-%d).pdf
+
+mkdir $CROSSWORDS_DIR/$(date +%Y-%m-%d)
+mv $CROSSWORDS_DIR/puzz#* $CROSSWORDS_DIR/$(date +%Y-%m-%d)
diff --git a/bin/.local/bin/scripts/nsxiv-pipe b/bin/.local/bin/scripts/nsxiv-pipe
new file mode 100755
index 0000000..ce3746b
--- /dev/null
+++ b/bin/.local/bin/scripts/nsxiv-pipe
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+tmpfile="${TMPDIR:-/tmp}/nsxiv_pipe_$$"
+trap 'rm -f -- "$tmpfile"' EXIT TERM INT QUIT
+
+if ! [ -t 0 ]; then
+ # drain stdin to tmpfile if it's not connected to a terminal
+ cat > "$tmpfile" || { echo "draining stdin failed" >&2; exit 1; }
+fi
+
+if [ -s "$tmpfile" ]; then
+ nsxiv "$tmpfile" "$@"
+else # fallback
+ [ "$#" -eq 0 ] && {
+ cat >&2 << EOF
+nsxiv-pipe: Error: no file or stdin provided
+Usage:
+ nsxiv-pipe < /path/to/file
+ curl "\$image_url" | nsxiv-pipe
+EOF
+ exit 1;
+ }
+ nsxiv "$@"
+fi
diff --git a/bin/.local/bin/scripts/perl/convert-color b/bin/.local/bin/scripts/perl/convert-color
new file mode 100755
index 0000000..00c21d7
--- /dev/null
+++ b/bin/.local/bin/scripts/perl/convert-color
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+# Check for at least one color code
+die "Usage: convert-color #hexcolor [#hexcolor ...]\n" unless @ARGV;
+
+foreach my $hex (@ARGV) {
+ # Validate and strip the leading #
+ if ($hex =~ /^#?([a-fA-F0-9]{6})$/) {
+ my $color = $1;
+
+ # Split into RGB components
+ my ($r, $g, $b) = map { hex($_) } ($color =~ /(..)(..)(..)/);
+
+ # Output in rgba format with alpha = 1
+ print "rgba($r, $g, $b, 1)\n";
+ } else {
+ warn "Invalid color format: $hex\n";
+ }
+}
diff --git a/bin/.local/bin/scripts/perl/forecast b/bin/.local/bin/scripts/perl/forecast
new file mode 100755
index 0000000..88a39ca
--- /dev/null
+++ b/bin/.local/bin/scripts/perl/forecast
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use LWP::UserAgent;
+use JSON::PP;
+use POSIX qw(strftime);
+use Time::Piece;
+use Text::Table;
+use Term::ANSIColor;
+
+# Setup
+my $url = 'https://api.weather.gov/gridpoints/LMK/56,80/forecast';
+my $ua = LWP::UserAgent->new;
+$ua->agent("CoolWeatherClient/1.0");
+
+# Fetch the JSON
+my $res = $ua->get($url);
+die "Failed to get forecast: " . $res->status_line unless $res->is_success;
+
+# Decode JSON
+my $data = decode_json($res->decoded_content);
+my @periods = @{ $data->{properties}{periods} };
+
+# Prepare table
+my $tb = Text::Table->new(
+ colored("Period", "bold blue"),
+ colored("Start Time", "bold yellow"),
+ colored("End Time", "bold yellow"),
+ colored("Temperature", "bold red"),
+ colored("Precip (%)", "bold cyan"),
+ colored("Forecast", "bold green")
+);
+
+# Process and add rows
+for my $p (@periods) {
+ my $start = format_time($p->{startTime});
+ my $end = format_time($p->{endTime});
+ my $temp = sprintf("%d°F", $p->{temperature});
+ my $precip = defined $p->{probabilityOfPrecipitation}{value} ? $p->{probabilityOfPrecipitation}{value} : 0;
+ $tb->add(
+ $p->{name},
+ $start,
+ $end,
+ $temp,
+ "$precip%",
+ $p->{shortForecast}
+ );
+}
+
+# Output table
+print "\n", colored("7-Day Weather Forecast", "bold underline green"), "\n\n";
+print $tb;
+
+# Function to format date/time
+sub format_time {
+ my ($iso) = @_;
+ $iso =~ s/([+-]\d{2}):(\d{2})$/$1$2/;
+
+ my $t = Time::Piece->strptime($iso, "%Y-%m-%dT%H:%M:%S%z");
+ return $t->strftime("%Y-%m-%d (%a) %H:%M");
+}
+
+# Save to cache with color codes intact
+my $cache_file = "$ENV{HOME}/.cache/weather";
+
+open(my $fh, '>', $cache_file) or die "Cannot write to $cache_file: $!";
+print $fh colored("7-Day Weather Forecast", "bold underline green") . "\n\n";
+print $fh $tb;
+close $fh;
+
+print "Successfully wrote output to cache file\n";
diff --git a/bin/.local/bin/scripts/perl/sdownload b/bin/.local/bin/scripts/perl/sdownload
new file mode 100755
index 0000000..13a2c06
--- /dev/null
+++ b/bin/.local/bin/scripts/perl/sdownload
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+# Takes in files like this
+# Genre - link to spotify song
+# Places in ~/Music/Genre/downloaded.mp3
+
+use strict;
+use warnings;
+use File::Path qw(make_path);
+use File::HomeDir;
+
+my $file = $ARGV[0] or die "Usage: ./sdownload download.txt\n";
+
+open(my $fh, '<', $file) or die "Could not open file '$file': $!";
+
+while (my $line = <$fh>) {
+ chomp $line;
+ next unless $line =~ /^(.+?)\s*-\s*(https:\/\/open\.spotify\.com\/track\/[^\s?]+)/;
+ my ($genre, $url) = ($1, $2);
+
+ my $music_dir = File::HomeDir->my_home . "/Music/$genre";
+ make_path($music_dir) unless -d $music_dir;
+
+ print "Downloading $url into $music_dir...\n";
+ system("cd '$music_dir' && spotdl download '$url'");
+}
+
+close($fh);
diff --git a/bin/.local/bin/scripts/smart-launcher b/bin/.local/bin/scripts/smart-launcher
new file mode 100755
index 0000000..1253555
--- /dev/null
+++ b/bin/.local/bin/scripts/smart-launcher
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+if [ "$#" -eq 1 ]; then
+ selected=$(find $1 -mindepth 1 -maxdepth 1 -type d | fzf)
+else
+ exit 0
+fi
+
+base_dir=$1
+
+if [ -z "$selected" ]; then
+ exit 0
+fi
+
+case "$(basename $base_dir)" in
+ "Pictures")
+ nsxiv -t -r "$selected"
+ ;;
+ "Code" | "Repositories" | "Documents")
+ selected_name=$(basename "$selected" | tr . _)
+ tmux_running=$(pgrep tmux)
+
+ if [ -z "$TMUX" ] && [ -z "$tmux_running" ]; then
+ tmux new-session -s "$selected_name" -c "$selected"
+ exit 0
+ fi
+
+ if ! tmux has-session -t="$selected_name" 2> /dev/null; then
+ tmux new-session -ds "$selected_name" -c "$selected"
+ fi
+
+ # tmux switch-client -t "$selected"
+ tmux attach
+ ;;
+ "*")
+ echo "No default behaviour defined for $selected"
+ ;;
+
+esac
diff --git a/bin/.local/bin/scripts/tmux-sessionizer b/bin/.local/bin/scripts/tmux-sessionizer
index 119313d..a600859 100755
--- a/bin/.local/bin/scripts/tmux-sessionizer
+++ b/bin/.local/bin/scripts/tmux-sessionizer
@@ -3,7 +3,7 @@
if [ "$#" -eq 1 ]; then
selected=$1
else
- selected=$(find ~/.config/ ~/.local/bin/scripts/ ~/.local/bin/scripts/perl ~/.local/bin/scripts/status ~/Code/ ~/Documents/ -mindepth 1 -maxdepth 1 -type d | fzf)
+ selected=$(find ~/dotfiles-stow/ ~/Code/ ~/Repositories/ -mindepth 1 -maxdepth 1 -type d | fzf)
fi
if [ -z "$selected" ]; then