From c68b08d692f51a7b4b84b393a816c4998c0991d3 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 7 Jul 2023 16:33:59 -0500 Subject: [PATCH 1/6] Add some fun battery scripts --- os/linux/arch/provision.d/20-install-packages.bash | 1 + os/linux/bin/batmon | 6 ++++++ os/linux/bin/batteries-combined-wattage | 3 +++ os/linux/bin/batteries-watts | 5 +++++ os/linux/bin/battplot | 9 +++++++++ 5 files changed, 24 insertions(+) create mode 100755 os/linux/bin/batmon create mode 100755 os/linux/bin/batteries-combined-wattage create mode 100755 os/linux/bin/batteries-watts create mode 100755 os/linux/bin/battplot diff --git a/os/linux/arch/provision.d/20-install-packages.bash b/os/linux/arch/provision.d/20-install-packages.bash index 3d18719..2582f12 100755 --- a/os/linux/arch/provision.d/20-install-packages.bash +++ b/os/linux/arch/provision.d/20-install-packages.bash @@ -52,4 +52,5 @@ paru -Sy --needed --noconfirm \ gnu-netcat socat websocat `# Socket Utilities` \ nnn `# CLI File Manager` \ avahi nss-mdns `# mDNS and Network Discovery Utilities` \ + git git-lfs `# Version Control` \ man-db man-pages `# Come On, Man!` diff --git a/os/linux/bin/batmon b/os/linux/bin/batmon new file mode 100755 index 0000000..7e27575 --- /dev/null +++ b/os/linux/bin/batmon @@ -0,0 +1,6 @@ +#!/usr/bin/env fish + +while true + echo (date +%s)' '(batteries-combined-wattage) >> ~/.battlog + sleep 5 +end diff --git a/os/linux/bin/batteries-combined-wattage b/os/linux/bin/batteries-combined-wattage new file mode 100755 index 0000000..e029734 --- /dev/null +++ b/os/linux/bin/batteries-combined-wattage @@ -0,0 +1,3 @@ +#!/usr/bin/env fish + +cat /sys/class/power_supply/BAT*/power_now | rg . | awk '{print $1*10^-6}' | awk '{sum+=$1}END{print sum}' diff --git a/os/linux/bin/batteries-watts b/os/linux/bin/batteries-watts new file mode 100755 index 0000000..c971b9b --- /dev/null +++ b/os/linux/bin/batteries-watts @@ -0,0 +1,5 @@ +#!/usr/bin/env fish + +for b in /sys/class/power_supply/BAT*/power_now + cat $b | rg . | awk '{print $1*10^-6 " W"}' +end diff --git a/os/linux/bin/battplot b/os/linux/bin/battplot new file mode 100755 index 0000000..9060fe60 --- /dev/null +++ b/os/linux/bin/battplot @@ -0,0 +1,9 @@ +#!/usr/bin/env fish +echo ' +set xdata time +set timefmt "%s" +set format x "%H:%M:%S" +# set yrange[0:96] +while (1) { plot "/home/daniel/.home/.battlog" using 1:2 with linespoints +pause 5 } +' | gnuplot From 09e48ac8fbb1b1b32a5476ed4bc8623ae285d2ae Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 7 Jul 2023 21:04:19 -0500 Subject: [PATCH 2/6] Zellij auto attach --- common/fish/config.fish | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/fish/config.fish b/common/fish/config.fish index 7226fba..81c1890 100755 --- a/common/fish/config.fish +++ b/common/fish/config.fish @@ -60,6 +60,8 @@ end # If we're running the shell interactively from inside Kitty, assume that we will be using Kitty's multiplexing features # Otherwise, assume we're in a context that is not capable of "native" multiplexing features and run everything inside Zellij if set --query FISH_START_ZELLIJ + set ZELLIJ_AUTO_ATTACH true + set ZELLIJ_AUTO_EXIT true eval (zellij setup --generate-auto-start fish | string collect) else if set --query FISH_START_TMUX tmux att -t default || tmux new -s default From 08a40f4ad5dbcc852851c31ce97ffd9f38f1daea Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sat, 8 Jul 2023 01:30:19 -0500 Subject: [PATCH 3/6] Z --- common/fish/config.fish | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/fish/config.fish b/common/fish/config.fish index 81c1890..c532882 100755 --- a/common/fish/config.fish +++ b/common/fish/config.fish @@ -59,10 +59,11 @@ end # If we're running the shell interactively from inside Kitty, assume that we will be using Kitty's multiplexing features # Otherwise, assume we're in a context that is not capable of "native" multiplexing features and run everything inside Zellij -if set --query FISH_START_ZELLIJ - set ZELLIJ_AUTO_ATTACH true - set ZELLIJ_AUTO_EXIT true - eval (zellij setup --generate-auto-start fish | string collect) -else if set --query FISH_START_TMUX +if set --query FISH_START_ZELLIJ && status is-interactive + # simulate auto attach + zellij attach -c || zellij attach -c (zellij list-sessions | grep -v '(current)' | head -n 1) || zellij + # simulate auto kill + kill $fish_pid +else if set --query FISH_START_TMUX && status is-interactive tmux att -t default || tmux new -s default end \ No newline at end of file From 0bdb01b739877b5c2e8092f800b9bdba40b4c5a9 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sat, 8 Jul 2023 01:31:58 -0500 Subject: [PATCH 4/6] Z --- common/fish/config.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/fish/config.fish b/common/fish/config.fish index c532882..c9c6663 100755 --- a/common/fish/config.fish +++ b/common/fish/config.fish @@ -61,7 +61,7 @@ end # Otherwise, assume we're in a context that is not capable of "native" multiplexing features and run everything inside Zellij if set --query FISH_START_ZELLIJ && status is-interactive # simulate auto attach - zellij attach -c || zellij attach -c (zellij list-sessions | grep -v '(current)' | head -n 1) || zellij + zellij attach -c # simulate auto kill kill $fish_pid else if set --query FISH_START_TMUX && status is-interactive From afed5fa6bbb6bc2733a3cadcb940d6599823b59d Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sat, 8 Jul 2023 01:33:24 -0500 Subject: [PATCH 5/6] Nest --- common/fish/config.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/fish/config.fish b/common/fish/config.fish index c9c6663..c62e5a7 100755 --- a/common/fish/config.fish +++ b/common/fish/config.fish @@ -59,11 +59,11 @@ end # If we're running the shell interactively from inside Kitty, assume that we will be using Kitty's multiplexing features # Otherwise, assume we're in a context that is not capable of "native" multiplexing features and run everything inside Zellij -if set --query FISH_START_ZELLIJ && status is-interactive +if not set --query ZELLIJ && set --query FISH_START_ZELLIJ && status is-interactive # simulate auto attach zellij attach -c # simulate auto kill kill $fish_pid -else if set --query FISH_START_TMUX && status is-interactive +else if not set --query TMUX && set --query FISH_START_TMUX && status is-interactive tmux att -t default || tmux new -s default end \ No newline at end of file From 286dc1eb3825c3fc383f0ce0b65235be7c03f259 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Mon, 10 Jul 2023 22:22:40 -0500 Subject: [PATCH 6/6] BSD --- common/fish/prompt.fish | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/fish/prompt.fish b/common/fish/prompt.fish index 1697b85..cf5c87d 100644 --- a/common/fish/prompt.fish +++ b/common/fish/prompt.fish @@ -1,7 +1,12 @@ set MAX_PATH_PIECE_CHARS 3 function get_hostname - has_command hostname && hostname --short || cat /etc/hostname + if test (uname) = Linux || test (uname) = Darwin + has_command hostname && hostname --short || cat /etc/hostname + else + # assume bsd + hostname | head -n 1 + end end function fish_greeting