Compare commits
10 Commits
4af7235289
...
a92d475e60
Author | SHA1 | Date |
---|---|---|
John Mertz | a92d475e60 | |
John Mertz | 7aa463ebc1 | |
John Mertz | 070613790f | |
John Mertz | 88ea557246 | |
John Mertz | fd9ae59e09 | |
John Mertz | be4b5bd30c | |
John Mertz | a2655a2ef4 | |
John Mertz | 3731844d4d | |
John Mertz | a3a98abe23 | |
John Mertz | e3b98b7aac |
66
README.md
66
README.md
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
## Audio
|
## Audio
|
||||||
|
|
||||||
**audio/mute.sh**
|
[**audio/mute.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/audio/mute.sh)
|
||||||
|
|
||||||
Just a simple script to toggle Alsa mute.
|
Just a simple script to toggle Alsa mute.
|
||||||
|
|
||||||
**audio/noise-cancel.sh**
|
[**audio/noise-cancel.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/audio/noise-cancel.sh)
|
||||||
|
|
||||||
Add a noise-cancelled version of existing interfaces to Pulseaudio.
|
Add a noise-cancelled version of existing interfaces to Pulseaudio.
|
||||||
|
|
||||||
**audio/stream-podcasts.pl**
|
[**audio/stream-podcasts.pl**](https://git.john.me.tz/jpm/scripts/src/branch/master/audio/stream-podcasts.pl)
|
||||||
|
|
||||||
Commandline podcast streamer. Fetchs the feed for desired podcasts, find items
|
Commandline podcast streamer. Fetchs the feed for desired podcasts, find items
|
||||||
published today, then plays them in order. Given arguments, it will use those
|
published today, then plays them in order. Given arguments, it will use those
|
||||||
|
@ -21,27 +21,23 @@ as feeds, otherwise it will use the hash listed in the script.
|
||||||
I haven't used i3 in earnest for quite some time since moving to Sway, so it is
|
I haven't used i3 in earnest for quite some time since moving to Sway, so it is
|
||||||
very likely that some of these scripts are broken based on other config changes.
|
very likely that some of these scripts are broken based on other config changes.
|
||||||
|
|
||||||
**i3/i3move.sh**
|
[**i3/i3move.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/i3/i3move.sh)
|
||||||
|
|
||||||
When any of the Xrandr scripts below is run, it will print it's name to a config
|
When any of the Xrandr scripts below is run, it will print it's name to a config
|
||||||
file. This script will read that config file and then knows how the outputs are
|
file. This script will read that config file and then knows how the outputs are
|
||||||
arranged. Once this is known, it allows hotkeys to know which output to move a
|
arranged. Once this is known, it allows hotkeys to know which output to move a
|
||||||
workspace to.
|
workspace to.
|
||||||
|
|
||||||
**i3/detached.sh**
|
[**i3/detached.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/i3/detached.sh)
|
||||||
|
|
||||||
Xrandr config. Just the laptop display.
|
Xrandr config. Just the laptop display.
|
||||||
|
|
||||||
**i3/detached.sh**
|
[**i3/home.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/i3/home.sh)
|
||||||
|
|
||||||
Xrandr config. Just the laptop display.
|
|
||||||
|
|
||||||
**i3/home.sh**
|
|
||||||
|
|
||||||
Xrandr config. Not a layout I currently use. Home is now the "stacked" view from
|
Xrandr config. Not a layout I currently use. Home is now the "stacked" view from
|
||||||
sway/displays.
|
sway/displays.
|
||||||
|
|
||||||
**i3/work.sh**
|
[**i3/work.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/i3/work.sh)
|
||||||
|
|
||||||
Xrandr config. Vertical on the left, horizontal aligned to top of the vertical,
|
Xrandr config. Vertical on the left, horizontal aligned to top of the vertical,
|
||||||
and laptop directly below that. Left-to-right order is
|
and laptop directly below that. Left-to-right order is
|
||||||
|
@ -53,28 +49,28 @@ Vertical-Horizontal-Laptop.
|
||||||
system. I use it for a bunch of stuff to supplement i3 and Sway to fill out same
|
system. I use it for a bunch of stuff to supplement i3 and Sway to fill out same
|
||||||
desktop niceties. See configs in 'dotfiles' repository.
|
desktop niceties. See configs in 'dotfiles' repository.
|
||||||
|
|
||||||
**rofi/drun.sh**
|
[**rofi/drun.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/rofi/drun.sh)
|
||||||
|
|
||||||
Simple launcher.
|
Simple launcher.
|
||||||
|
|
||||||
**rofi/rofi-openvpn.sh**
|
[**rofi/rofi-openvpn.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/rofi/rofi-openvpn.sh)
|
||||||
|
|
||||||
Quick VPN switcher.
|
Quick VPN switcher.
|
||||||
|
|
||||||
**rofi/rofi-power-menu.sh**
|
[**rofi/rofi-power-menu.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/rofi/rofi-power-menu.sh)
|
||||||
|
|
||||||
Lock, log out, restart Sway/i3, restart waybar, hibernate, reboot, shutdown.
|
Lock, log out, restart Sway/i3, restart waybar, hibernate, reboot, shutdown.
|
||||||
|
|
||||||
**rofi/rofi-send-to-kodi.sh**
|
[**rofi/rofi-send-to-kodi.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/rofi/rofi-send-to-kodi.sh)
|
||||||
|
|
||||||
Forward pasted link to ./send-to-kodi.sh.
|
Forward pasted link to ./send-to-kodi.sh.
|
||||||
|
|
||||||
**rofi/rofi-ssh-menu.sh**
|
[**rofi/rofi-ssh-menu.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/rofi/rofi-ssh-menu.sh)
|
||||||
|
|
||||||
Open a terminal to any SSH shortcut machine. (TODO: Integrate with 'sshs' to get
|
Open a terminal to any SSH shortcut machine. (TODO: Integrate with 'sshs' to get
|
||||||
machine list from there instead of a static list).
|
machine list from there instead of a static list).
|
||||||
|
|
||||||
**rofi/sway-alt-tab.sh**
|
[**rofi/sway-alt-tab.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/sway/sway-alt-tab.sh)
|
||||||
|
|
||||||
Show all currently running applications in Sway to locate window.
|
Show all currently running applications in Sway to locate window.
|
||||||
|
|
||||||
|
@ -84,14 +80,14 @@ Show all currently running applications in Sway to locate window.
|
||||||
and tiling window manager. See configs in 'dotfiles' repository. Here are some
|
and tiling window manager. See configs in 'dotfiles' repository. Here are some
|
||||||
scripts exclusively for automating or enhancing Sway.
|
scripts exclusively for automating or enhancing Sway.
|
||||||
|
|
||||||
**sway/displays.pl**
|
[**sway/displays.pl**](https://git.john.me.tz/jpm/scripts/src/branch/master/sway/displays.pl)
|
||||||
|
|
||||||
Script to automatically configure wayland outputs using swaymsg. Also forks
|
Script to automatically configure wayland outputs using swaymsg. Also forks
|
||||||
waybars for each display. Allows custom configurations. No argument will run the
|
waybars for each display. Allows custom configurations. No argument will run the
|
||||||
last used configuration (~/config/last_display). '-w' will run only waybar
|
last used configuration (~/config/last_display). '-w' will run only waybar
|
||||||
without changing displays.
|
without changing displays.
|
||||||
|
|
||||||
**sway/gammastep.pl**
|
[**sway/gammastep.pl**](https://git.john.me.tz/jpm/scripts/src/branch/master/sway/gammastep.pl)
|
||||||
|
|
||||||
Setup Gammastep based on current location. I don't have geolocation in my
|
Setup Gammastep based on current location. I don't have geolocation in my
|
||||||
laptop, so this requires a URL that returns JSON, including a "lat" and "lon".
|
laptop, so this requires a URL that returns JSON, including a "lat" and "lon".
|
||||||
|
@ -105,7 +101,7 @@ phone similar to:
|
||||||
It forks to keep running if terminal is killed. If location fails to be fetched
|
It forks to keep running if terminal is killed. If location fails to be fetched
|
||||||
it will try again every 5 seconds.
|
it will try again every 5 seconds.
|
||||||
|
|
||||||
**sway/popup-term.pl**
|
[**sway/popup-term.pl**](https://git.john.me.tz/jpm/scripts/src/branch/master/sway/popup-term.pl)
|
||||||
|
|
||||||
A DIY version of the Tilde terminal. If terminal is not running, it opens on the
|
A DIY version of the Tilde terminal. If terminal is not running, it opens on the
|
||||||
current display. If it is running but not on current dislpay, it moves to
|
current display. If it is running but not on current dislpay, it moves to
|
||||||
|
@ -135,7 +131,7 @@ it to be *hidden*.
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
**sway/swayidle.sh**
|
[**sway/swayidle.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/sway/swayidle.sh)
|
||||||
|
|
||||||
Work in progress. These scripts don't currently work the way I like.
|
Work in progress. These scripts don't currently work the way I like.
|
||||||
|
|
||||||
|
@ -145,26 +141,32 @@ certain periods of inactivity as well as prior to sleep and after wake.
|
||||||
This script is meant to unify all of the actions into one script by accepting an
|
This script is meant to unify all of the actions into one script by accepting an
|
||||||
option.
|
option.
|
||||||
|
|
||||||
**sway/swayidlecountdown.sh**
|
[**sway/swayidlecountdown.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/sway/swayidlecountdown.sh)
|
||||||
|
|
||||||
Prior to locking a countdown should be provided. Currently testing how to manage
|
Prior to locking a countdown should be provided. Currently testing how to manage
|
||||||
a countdown with Dunst, which doesn't actually support dynamic notifications.
|
a countdown with Dunst, which doesn't actually support dynamic notifications.
|
||||||
|
|
||||||
## Thinkpad
|
## Thinkpad
|
||||||
|
|
||||||
**thinkpad/blc.pl**
|
[**thinkpad/blc.pl**](https://git.john.me.tz/jpm/scripts/src/branch/master/thinkpad/blc.pl)
|
||||||
|
|
||||||
Overly complicated backlight brightness control script. Provides flexible
|
Overly complicated backlight brightness control script. Provides flexible
|
||||||
control of backlight so that changes can be easily scripted or called from
|
control of backlight so that changes can be easily scripted or called from
|
||||||
keyboard shortcuts. --help provides some usage docs.
|
keyboard shortcuts. --help provides some usage docs.
|
||||||
|
|
||||||
**thinkpad/kbd_backlight.pl**
|
[**thinkpad/kbd_backlight.pl**](https://git.john.me.tz/jpm/scripts/src/branch/master/thinkpad/kbd_backlight.pl)
|
||||||
|
|
||||||
Simple script to cycle keyboard backlight. Gets max brightness, current
|
Simple script to cycle keyboard backlight. Gets max brightness, current
|
||||||
brightness and then changes then increments the current brightness. Uses mod of
|
brightness and then changes then increments the current brightness. Uses mod of
|
||||||
max+1 so that it will cycle back around to 0 (disabled) if it is already at max.
|
max+1 so that it will cycle back around to 0 (disabled) if it is already at max.
|
||||||
|
|
||||||
**thinkpad/user-thinkpad-control@.service**
|
[**thinkpad/pow.pl**](https://git.john.me.tz/jpm/scripts/src/branch/master/thinkpad/pow.pl)
|
||||||
|
|
||||||
|
Overly complicated battery and power status fetcher script. Can output stats as
|
||||||
|
JSON, Waybar-friendly percentage and icon, or a pretty table suitable for use with
|
||||||
|
plain-text notifications via notify-send or similar.
|
||||||
|
|
||||||
|
[**thinkpad/user-thinkpad-controls@.service**](https://git.john.me.tz/jpm/scripts/src/branch/master/thinkpad/user-thinkpad-controls@.service)
|
||||||
|
|
||||||
SystemD unit file used to give ownership of necessary sys files to whichever
|
SystemD unit file used to give ownership of necessary sys files to whichever
|
||||||
user it is enabled for `systemctl enable user-thinkpad-control@jpm`. Without
|
user it is enabled for `systemctl enable user-thinkpad-control@jpm`. Without
|
||||||
|
@ -178,39 +180,39 @@ taskbar for Sway (and other Wlroots-based wayland compositors). Waybar applets
|
||||||
have hover and click functionality and have several scripts related to those.
|
have hover and click functionality and have several scripts related to those.
|
||||||
See the .config repository for the actual Waybar and Sway configs.
|
See the .config repository for the actual Waybar and Sway configs.
|
||||||
|
|
||||||
**waybar/waybar-cpu.sh**
|
[**waybar/waybar-cpu.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/waybar/waybar-cpu.sh)
|
||||||
|
|
||||||
Launch htop in floating window (bottom-right). If already running, kill it.
|
Launch htop in floating window (bottom-right). If already running, kill it.
|
||||||
|
|
||||||
**waybar/waybar-disk.sh**
|
[**waybar/waybar-disk.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/waybar/waybar-disk.sh)
|
||||||
|
|
||||||
Notification with disk usage summaries. Renders properly with Dunst, but not
|
Notification with disk usage summaries. Renders properly with Dunst, but not
|
||||||
Mako.
|
Mako.
|
||||||
|
|
||||||
**waybar/waybar-mem.sh**
|
[**waybar/waybar-mem.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/waybar/waybar-mem.sh)
|
||||||
|
|
||||||
Notification with memory usage summaries.
|
Notification with memory usage summaries.
|
||||||
|
|
||||||
**waybar/waybar-nmtui.sh**
|
[**waybar/waybar-nm.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/waybar/waybar-nm.sh)
|
||||||
|
|
||||||
Launch nmtui in floating window (bottom-right). If already running, kill it.
|
Launch nmtui in floating window (bottom-right). If already running, kill it.
|
||||||
|
|
||||||
## Miscellaneous
|
## Miscellaneous
|
||||||
|
|
||||||
**apply-gruvbox.sh**
|
[**apply-gruvbox.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/apply-gruvbox.sh)
|
||||||
|
|
||||||
A single theme version of the one provided
|
A single theme version of the one provided
|
||||||
[here](https://raw.githubusercontent.com/Mayccoll/Gogh). Applies the theme to a
|
[here](https://raw.githubusercontent.com/Mayccoll/Gogh). Applies the theme to a
|
||||||
variety of terminals. Not really necessary after cloning the 'dotfiles'
|
variety of terminals. Not really necessary after cloning the 'dotfiles'
|
||||||
repository.
|
repository.
|
||||||
|
|
||||||
**send-to-kodi.sh**
|
[**send-to-kodi.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/send-to-kodi.sh)
|
||||||
|
|
||||||
[This script](https://github.com/allejok96/send-to-kodi) sends a URL or local
|
[This script](https://github.com/allejok96/send-to-kodi) sends a URL or local
|
||||||
file to a [Kodi](https://github.com/xbmc) media player. Only modified to have my
|
file to a [Kodi](https://github.com/xbmc) media player. Only modified to have my
|
||||||
local media server IP.
|
local media server IP.
|
||||||
|
|
||||||
**setup_wireguard.sh**
|
[**setup_wireguard.sh**](https://git.john.me.tz/jpm/scripts/src/branch/master/setup_wireguard.sh)
|
||||||
|
|
||||||
Script to install WireGuard and generate a config file. Requires modification
|
Script to install WireGuard and generate a config file. Requires modification
|
||||||
with the server public IP, server public key, and change to first 3 octets if
|
with the server public IP, server public key, and change to first 3 octets if
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
res=$(echo "john.me.tz|root@john.me.tz|t470s.lan.john.me.tz|shb.ng|\
|
res=$(echo "john.me.tz|root@john.me.tz|t470s.lan.john.me.tz|shb.ng|\
|
||||||
kipary.mailcleaner.net|media.lan.john.me.tz|pipcam.lan.john.me.tz|\
|
kipary.fastnet.ch|media.lan.john.me.tz|pipcam0.lan.john.me.tz|\
|
||||||
therm.lan.john.me.tz|hud.lan.john.me.tz|vm.lan.john.me.tz" | \
|
therm.lan.john.me.tz|hud.lan.john.me.tz|vm.lan.john.me.tz|mac.lan.john.me.tz|AndroidUSB" | \
|
||||||
rofi -sep "|" -dmenu -i -p 'P ' "" -columns 1 -rows 1 -width 45 -l 1 -config \
|
rofi -sep "|" -dmenu -i -p 'P ' "" -columns 1 -rows 1 -width 45 -l 1 -config \
|
||||||
/home/jpm/.config/rofi/config -hide-scrollbar -eh 1 -location 0 -yoffset 0 \
|
/home/jpm/.config/rofi/config -hide-scrollbar -eh 1 -location 0 -yoffset 0 \
|
||||||
-padding 12 -opacity 100 -auto-select -no-fullscreen)
|
-padding 12 -opacity 100 -auto-select -no-fullscreen)
|
||||||
|
|
||||||
|
echo $res > /home/jpm/.last_ssh_shortcut
|
||||||
if [ $res = "john.me.tz" ]; then
|
if [ $res = "john.me.tz" ]; then
|
||||||
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs w'
|
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs w'
|
||||||
elif [ $res = "root@john.me.tz" ]; then
|
elif [ $res = "root@john.me.tz" ]; then
|
||||||
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs r'
|
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs r'
|
||||||
elif [ $res = "shb.ng" ]; then
|
elif [ $res = "shb.ng" ]; then
|
||||||
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs s'
|
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs s'
|
||||||
elif [ $res = "kipary.mailcleaner.net" ]; then
|
elif [ $res = "kipary.fastnet.ch" ]; then
|
||||||
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs d'
|
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs d'
|
||||||
elif [ $res = "camera.lan.john.me.tz" ]; then
|
elif [ $res = "camera.lan.john.me.tz" ]; then
|
||||||
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs c'
|
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs c'
|
||||||
|
@ -29,5 +30,9 @@ elif [ $res = "therm.lan.john.me.tz" ]; then
|
||||||
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs t'
|
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs t'
|
||||||
elif [ $res = "vm.lan.john.me.tz" ]; then
|
elif [ $res = "vm.lan.john.me.tz" ]; then
|
||||||
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs v'
|
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs v'
|
||||||
|
elif [ $res = "mac.lan.john.me.tz" ]; then
|
||||||
|
/usr/bin/gvncviewer 192.168.2.10 >> /home/jpm/macos
|
||||||
|
elif [ $res = "AndroidUSB" ]; then
|
||||||
|
/usr/bin/scrcpy
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Required settings
|
# Required settings
|
||||||
host=10.10.0.66
|
host=192.168.2.66
|
||||||
port=8080
|
port=8080
|
||||||
|
|
||||||
# Optional login for Kodi
|
# Optional login for Kodi
|
||||||
#user=
|
user=kodi
|
||||||
#pass=
|
pass=kodi
|
||||||
|
|
||||||
# Settings for netcat (local file)
|
# Settings for netcat (local file)
|
||||||
local_hostname=$(hostname)
|
local_hostname=$(hostname)
|
||||||
|
|
|
@ -50,10 +50,9 @@ my $active_outputs = "$ENV{'HOME'}/.config/active_outputs";
|
||||||
my %outputs = (
|
my %outputs = (
|
||||||
#'0x00000101' => 'Sam',
|
#'0x00000101' => 'Sam',
|
||||||
'HTNCB00059' => 'Sam',
|
'HTNCB00059' => 'Sam',
|
||||||
#'3CQ3310Q1Q' => 'Sam',
|
#'3CQ4342S6W' => 'HP-1',
|
||||||
'3CQ4342S6W' => 'HP-1',
|
'0x00000101' => 'HP-1',
|
||||||
'0x00000101' => 'HP-2',
|
'3CQ3310Q1Q' => 'HP-2',
|
||||||
#'3CQ3310Q1Q' => 'HP-2',
|
|
||||||
'0x00000000' => 'LVDS'
|
'0x00000000' => 'LVDS'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ my %configs = (
|
||||||
'Sam' => {
|
'Sam' => {
|
||||||
'on' => 1,
|
'on' => 1,
|
||||||
'width' => 1920,
|
'width' => 1920,
|
||||||
'height' => 1080,
|
'height' => 1280,
|
||||||
'x' => 960,
|
'x' => 960,
|
||||||
'y' => 0,
|
'y' => 0,
|
||||||
'rotate' => 0,
|
'rotate' => 0,
|
||||||
|
|
|
@ -8,11 +8,8 @@ use warnings;
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use JSON::XS;
|
use JSON::XS;
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new();
|
|
||||||
my $json = JSON::XS->new();
|
|
||||||
my $location = "https://papillon.john.me.tz/data/location.json";
|
my $location = "https://papillon.john.me.tz/data/location.json";
|
||||||
|
my $lat_lon = fetch_lat_lon($location);
|
||||||
my $lat_lon = fetch_lat_lon($ua, $json, $location);
|
|
||||||
|
|
||||||
my $pid = fork;
|
my $pid = fork;
|
||||||
unless ($pid) {
|
unless ($pid) {
|
||||||
|
@ -25,10 +22,15 @@ unless ($pid) {
|
||||||
|
|
||||||
sub fetch_lat_lon
|
sub fetch_lat_lon
|
||||||
{
|
{
|
||||||
my ($ua, $json, $location) = @_;
|
my ($location) = shift;
|
||||||
|
|
||||||
|
my $ua = LWP::UserAgent->new();
|
||||||
|
my $json = JSON::XS->new();
|
||||||
|
|
||||||
my $raw = $ua->get($location)->content();
|
my $raw = $ua->get($location)->content();
|
||||||
|
|
||||||
if (defined $raw) {
|
if (defined $raw) {
|
||||||
|
print($raw."\n");
|
||||||
my $decoded = $json->decode($raw);
|
my $decoded = $json->decode($raw);
|
||||||
if (defined $decoded->{lat} && defined $decoded->{lon}) {
|
if (defined $decoded->{lat} && defined $decoded->{lon}) {
|
||||||
return "$decoded->{lat}:$decoded->{lon}";
|
return "$decoded->{lat}:$decoded->{lon}";
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
my $output;
|
||||||
|
my ($bar, $pretty) = (0, 0);
|
||||||
|
|
||||||
|
if ( defined($ARGV[0]) && $ARGV[0] ne '-b' && $ARGV[0] ne '--bar' && $ARGV[0] ne '-p' && $ARGV[0] ne '--pretty' ) {
|
||||||
|
print'
|
||||||
|
pow.pl - Power Status Script
|
||||||
|
|
||||||
|
Usage: pow.pl
|
||||||
|
|
||||||
|
Prints information about all power devices as JSON.
|
||||||
|
|
||||||
|
-p --pretty Display as human-readable
|
||||||
|
-b --bar Waybar simplified output
|
||||||
|
-h --help Display help. This is the only option.
|
||||||
|
|
||||||
|
';
|
||||||
|
exit();
|
||||||
|
} elsif ($ARGV[0] eq '-b' || $ARGV[0] eq '--bar') {
|
||||||
|
$bar = 1;
|
||||||
|
} elsif ($ARGV[0] eq '-p' || $ARGV[0] eq '--pretty') {
|
||||||
|
$pretty = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my %battery_total = (
|
||||||
|
'current' => 0,
|
||||||
|
'max' => 0,
|
||||||
|
'percentage' => 0
|
||||||
|
);
|
||||||
|
|
||||||
|
my @devices = <"/sys/class/power_supply/*">;
|
||||||
|
$output .= "{";
|
||||||
|
foreach (@devices) {
|
||||||
|
my $path = $_;
|
||||||
|
my $name = $_;
|
||||||
|
$name =~ s/.*\///;
|
||||||
|
$output .= '"' . $name . '":{';
|
||||||
|
open(my $t,'<',"$_/type");
|
||||||
|
my $type = <$t>;
|
||||||
|
chomp $type;
|
||||||
|
close $t;
|
||||||
|
$output .= '"Type":"' . $type . '"';
|
||||||
|
if ($name =~ /BAT[0-9]+/) {
|
||||||
|
open(my $s,'<',"$_/status");
|
||||||
|
my $status = <$s>;
|
||||||
|
chomp $status;
|
||||||
|
$output .= ',"Status":"' . $status . '"';
|
||||||
|
} else {
|
||||||
|
open(my $s,'<',"$_/online");
|
||||||
|
my $status = <$s>;
|
||||||
|
chomp $status;
|
||||||
|
if ($status) {
|
||||||
|
$status = "Plugged-In";
|
||||||
|
} else {
|
||||||
|
$status = "Unplugged";
|
||||||
|
}
|
||||||
|
$output .= ',"Status":"' . $status . '"';
|
||||||
|
}
|
||||||
|
close $s;
|
||||||
|
if ($name =~ /BAT[0-9]+/) {
|
||||||
|
open(my $m,'<',"$_/energy_full");
|
||||||
|
my $max = <$m>;
|
||||||
|
close $m;
|
||||||
|
chomp $max;
|
||||||
|
$battery_total{'max'} += $max;
|
||||||
|
open(my $c,'<',"$_/energy_now");
|
||||||
|
my $current = <$c>;
|
||||||
|
chomp $current;
|
||||||
|
#$current =~ s/\n//;
|
||||||
|
$battery_total{'current'} += $current;
|
||||||
|
close $c;
|
||||||
|
$output .= ',"Current":"'
|
||||||
|
. $current
|
||||||
|
. '","Max":"'
|
||||||
|
. $max
|
||||||
|
. '","Percentage":"'
|
||||||
|
. int($current/$max*100)
|
||||||
|
. '"';
|
||||||
|
}
|
||||||
|
$output .= "},";
|
||||||
|
}
|
||||||
|
|
||||||
|
$battery_total{'percentage'} = sprintf("%0d",
|
||||||
|
$battery_total{'current'} / $battery_total{'max'} * 100
|
||||||
|
);
|
||||||
|
$output .= '"Total":{"Current":"'
|
||||||
|
. $battery_total{'current'}
|
||||||
|
. '","Max":"'
|
||||||
|
. $battery_total{'max'}
|
||||||
|
. '","Percentage":"'
|
||||||
|
. $battery_total{'percentage'}
|
||||||
|
. '"}}';
|
||||||
|
|
||||||
|
if ($bar) {
|
||||||
|
use JSON::XS;
|
||||||
|
my $json = JSON::XS->new();
|
||||||
|
my $powref = $json->decode($output);
|
||||||
|
my $icon;
|
||||||
|
my $class = 'discharging';
|
||||||
|
$output = '{"text": "' . $powref->{Total}->{Percentage} . '% ';
|
||||||
|
if ($powref->{AC}->{Status} eq "Plugged-In") {
|
||||||
|
$class = 'charging';
|
||||||
|
$output .= "";
|
||||||
|
} elsif ($powref->{Total}->{Percentage} le 10) {
|
||||||
|
$class = 'critical';
|
||||||
|
$output .= "";
|
||||||
|
} elsif ($powref->{Total}->{Percentage} le 35) {
|
||||||
|
$class = 'low';
|
||||||
|
$output .= "";
|
||||||
|
} elsif ($powref->{Total}->{Percentage} le 60) {
|
||||||
|
$output .= "";
|
||||||
|
} elsif ($powref->{Total}->{Percentage} le 85) {
|
||||||
|
$output .= "";
|
||||||
|
} else {
|
||||||
|
$output .= "";
|
||||||
|
}
|
||||||
|
$output .= '", "tooltip": "' . $class . '", "class": "' . $class . '"}';
|
||||||
|
} elsif ($pretty) {
|
||||||
|
use JSON::XS;
|
||||||
|
my $json = JSON::XS->new();
|
||||||
|
my $powref = $json->decode($output);
|
||||||
|
my $total = '';
|
||||||
|
$output = "Device Status Percentage\n";
|
||||||
|
foreach my $device (keys %{$powref}) {
|
||||||
|
my $status;
|
||||||
|
if ($powref->{$device}->{Status} eq "Plugged-In") {
|
||||||
|
$status = "";
|
||||||
|
} elsif (!defined($powref->{$device}->{Percentage}) || $powref->{$device}->{Percentage} == 0) {
|
||||||
|
$status = " ";
|
||||||
|
} elsif ($powref->{$device}->{Percentage} <= 10) {
|
||||||
|
$status = " " . $powref->{$device}->{'Percentage'} . "%";
|
||||||
|
} elsif ($powref->{$device}->{Percentage} <= 35) {
|
||||||
|
$status = " " . $powref->{$device}->{'Percentage'} . "%";
|
||||||
|
} elsif ($powref->{$device}->{Percentage} <= 60) {
|
||||||
|
$status = " " . $powref->{$device}->{'Percentage'} . "%";
|
||||||
|
} elsif ($powref->{$device}->{Percentage} <= 85) {
|
||||||
|
$status = " " . $powref->{$device}->{'Percentage'} . "%";
|
||||||
|
} else {
|
||||||
|
$status = " " . $powref->{$device}->{'Percentage'} . "%";
|
||||||
|
}
|
||||||
|
if ($device eq 'Total') {
|
||||||
|
$total .= sprintf("%-24s %-12s", $device, $status);
|
||||||
|
} else {
|
||||||
|
#$output .= sprintf("%".length($powref->{$device->{'Type'}})."s (%".length($powref->{$device->{'Type'}})."s): %3d\%\n", $device, $device->{'Type'}, $device->{'Percentage'});
|
||||||
|
my $name = ' ('.$powref->{$device}->{'Type'}.')';
|
||||||
|
if ((length($device)+length($name)) >= 24) {
|
||||||
|
$name = substr($device, 0, (21-length($name))) . '...' . $name;
|
||||||
|
} else {
|
||||||
|
$name = substr(($device.$name), 0, 24);
|
||||||
|
}
|
||||||
|
$output .= sprintf("%-24s %-12s %-12s\n", $name, $powref->{$device}->{Status}, $status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$output .= $total;
|
||||||
|
}
|
||||||
|
print $output . "\n";
|
||||||
|
|
||||||
|
exit();
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
RUNNING=$(pgrep nmtui)
|
||||||
|
|
||||||
|
if [ "$RUNNING" ]; then
|
||||||
|
kill $RUNNING 2&>1 /dev/null
|
||||||
|
else
|
||||||
|
/usr/bin/xterm -e '/usr/bin/nmtui'
|
||||||
|
fi
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ "$(pgrep -c nmtui | cut -b 1)" -eq "0" ]; then
|
|
||||||
echo true
|
|
||||||
/usr/bin/xterm -e '/usr/bin/nmtui'
|
|
||||||
else
|
|
||||||
echo false
|
|
||||||
pkill nmtui 2&>1 /dev/null
|
|
||||||
fi
|
|
Loading…
Reference in New Issue