Some general changes. Rewrote flowerfetch in lua
as well as python, although python is remianing uncommitted. A small xonotic script to display server status was created. A few mild changes on other things have been made, but otherwise nothing major is here. Likely should do cleanup.
This commit is contained in:
parent
72bab1ec6b
commit
4fc4066213
9
flower.txt
Normal file
9
flower.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
c[38;5;231m _ _
|
||||
(_\_)
|
||||
(_ [38;5;226m<_{}[38;5;231m
|
||||
(_/_) [38;5;82m
|
||||
|\ [38;5;70m| [38;5;82m
|
||||
\\[38;5;70m|[38;5;82m /|
|
||||
\[38;5;70m|[38;5;82m//
|
||||
[38;5;70m|[38;5;82m/
|
||||
[38;5;130m,.,.,[38;5;70m|[38;5;130m.,.,.[0m
|
121
flowerfetch.lua
Executable file
121
flowerfetch.lua
Executable file
|
@ -0,0 +1,121 @@
|
|||
#!/usr/bin/luajit
|
||||
|
||||
local lfs = require("lfs")
|
||||
|
||||
|
||||
local luadir = arg[0]:match("@?(.*/)");
|
||||
|
||||
-- Print out flower from text file
|
||||
local flower = io.open(luadir .. "flower.txt", "r");
|
||||
if (flower ~= nil) then
|
||||
print(flower:read("*a"));
|
||||
flower:close();
|
||||
else
|
||||
print("Error: Missing ASCII flower");
|
||||
os.exit(-1);
|
||||
end
|
||||
|
||||
for filename in lfs.dir("/sys/class/power_supply") do
|
||||
if filename ~= "." and filename ~= ".." and filename ~= "AC" then
|
||||
end
|
||||
end
|
||||
|
||||
function Getfile(loc, perm, splitstr, strip)
|
||||
local table = {};
|
||||
local gotfile = io.open(loc, perm);
|
||||
if (gotfile ~= nil) then
|
||||
for line in gotfile:lines() do
|
||||
for lineid, lineval in line:gmatch(splitstr) do
|
||||
table[lineid] = lineval:gsub(strip, "");
|
||||
end
|
||||
end
|
||||
gotfile:close();
|
||||
end
|
||||
return table;
|
||||
end
|
||||
|
||||
function Getline(loc)
|
||||
local item = io.open(loc, 'r')
|
||||
if (item ~= nil) then
|
||||
local str = item:read('*l')
|
||||
item:close()
|
||||
return str
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
-- Get battery stuff
|
||||
local battery = ""
|
||||
local batteries = ""
|
||||
for filename in lfs.dir("/sys/class/power_supply") do
|
||||
if filename ~= "." and filename ~= ".." and filename ~= "AC" then
|
||||
battery = Getline("/sys/class/power_supply/" .. filename .. "/capacity")
|
||||
batteries = string.format("[ %s %s%% ] ", filename, battery) .. batteries
|
||||
end
|
||||
end
|
||||
|
||||
-- Get wifi link quality
|
||||
local winit = {}
|
||||
local wifistring = ""
|
||||
local wifi = io.open('/proc/net/wireless', 'r')
|
||||
if (wifi ~= nil) then
|
||||
for line in wifi:lines() do
|
||||
table.insert(winit, line);
|
||||
end
|
||||
|
||||
-- what the fuck is lua regex.
|
||||
local wifiregex = "%s(.*):.*%s(%d+)%."
|
||||
|
||||
-- Assemble wifi into printable set of strings.
|
||||
for item = 1, #winit - 2 do
|
||||
for wif, wqual in winit[item + 2]:gmatch(wifiregex) do
|
||||
wifistring = wifistring .. string.format("[ %s %s%% ] ", wif, wqual)
|
||||
end
|
||||
end
|
||||
wifi:close()
|
||||
end
|
||||
|
||||
-- Get individual elements
|
||||
local model = Getline('/sys/devices/virtual/dmi/id/product_version');
|
||||
local kernel = Getline('/proc/sys/kernel/osrelease');
|
||||
local shell = os.getenv("SHELL"):gsub(".*/", "");
|
||||
local osrel = Getfile("/etc/os-release", "r", "(.*)=(.*)", "\"");
|
||||
local uptime = Getline("/proc/uptime"):gsub("%..*", "");
|
||||
local up_d = math.floor(uptime / (3600 * 24))
|
||||
local up_h = math.floor((uptime % (3600 * 24)) / 3600)
|
||||
local up_m = math.floor(((uptime % (3600 * 24)) % 3600) / 60)
|
||||
|
||||
local upstring = ""
|
||||
if up_d > 0 then
|
||||
upstring = string.format("%sd %sh %sm", up_d, up_h, up_m)
|
||||
elseif up_h > 0 then
|
||||
upstring = string.format("%sh %sm", up_d, up_h, up_m)
|
||||
else
|
||||
upstring = string.format("%sm", up_d, up_h, up_m)
|
||||
end
|
||||
|
||||
local output = {
|
||||
{ "model", model },
|
||||
{ "distro", osrel['PRETTY_NAME'] },
|
||||
{ "kernel", kernel },
|
||||
{ "shell", shell },
|
||||
{ "uptime", upstring },
|
||||
{ "bat", batteries },
|
||||
{ "wifi", wifistring },
|
||||
};
|
||||
|
||||
local count = 0;
|
||||
for _, value in pairs(output) do
|
||||
local color = "";
|
||||
if count == 0 then
|
||||
color = "\27[34m";
|
||||
count = count + 1;
|
||||
else
|
||||
color = "\27[36m";
|
||||
count = 0;
|
||||
end
|
||||
|
||||
print(string.format("%s%6s \27[37m-\27[37m %s", color, value[1], value[2]))
|
||||
end
|
||||
print()
|
|
@ -1,72 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
leaf=$'\e[38;5;82m'
|
||||
stem=$'\e[38;5;70m'
|
||||
ground=$'\e[38;5;130m'
|
||||
stamen=$'\e[38;5;226m'
|
||||
flower=$'\e[38;5;231m'
|
||||
|
||||
truered=$'\e[38;5;160m'
|
||||
truegrn=$'\e[38;5;82m'
|
||||
|
||||
white=$'\e[0m'
|
||||
c1=$'\e[31m'
|
||||
c4=$'\e[34m'
|
||||
c6=$'\e[36m'
|
||||
c7=$'\e[37m'
|
||||
|
||||
bats=()
|
||||
for battery in /sys/class/power_supply/BAT*;
|
||||
do
|
||||
baticon=""
|
||||
batstat=$(cat $battery/status)
|
||||
if [ $batstat == "Discharging" ]
|
||||
then
|
||||
baticon="$truered▼ "
|
||||
elif [ $batstat == "Charging" ]
|
||||
then
|
||||
baticon="$truegrn▲ "
|
||||
fi
|
||||
bats+=("[ $(basename $battery) $(cat $battery/capacity)% $baticon$c7]")
|
||||
done
|
||||
|
||||
distro=$(lsb_release -si)
|
||||
kern=$(uname -r | sed 's/\-.*//;')
|
||||
res=$(xrandr --current | grep ' connected' | sed 's/\+.*//;s/.* //;')
|
||||
shell=$(basename $SHELL)
|
||||
wmid=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK | sed 's/.*\s//;')
|
||||
wm=$(xprop -id "$wmid" -notype -len 100 -f _NET_WM_NAME 8t | grep 'WM_NAME' | sed 's/\"//g;s/.*\s//')
|
||||
model=$(cat /sys/devices/virtual/dmi/id/product_version)
|
||||
upt=$(cat /proc/uptime | sed 's/\..*//')
|
||||
days=$(echo $(( $upt / 60 / 60 / 24 ))d )
|
||||
hours=$(echo $(( $upt / 60 / 60 % 24 ))h )
|
||||
minutes=$(echo $(( $upt / 60 % 60 ))m )
|
||||
pkgs_aur=$(pacman -Qqm | wc -l)
|
||||
pkgs_total=$(pacman -Qq | wc -l)
|
||||
#pkgs_native=$(pacman -Qqn | wc -l)
|
||||
#pkgs_total=$(($pkgs_native + $pkgs_aur))
|
||||
wifi_quality=$(nmcli -f IN-USE,BARS device wifi list | awk '/*/ {print $2}')
|
||||
|
||||
tput clear
|
||||
cat << EOF
|
||||
$flower _ _
|
||||
(_\\_)
|
||||
(_ $stamen<_{}$flower
|
||||
(_/_)
|
||||
$leaf |\\ $stem|$leaf
|
||||
\\\\$stem|$leaf /|
|
||||
\\$stem|$leaf//
|
||||
$stem|$leaf/
|
||||
$ground,.,.,$stem|$ground.,.,.$c4
|
||||
model $white-$c7 $model $c6
|
||||
distro $white-$c7 $distro $c4
|
||||
kernel $white-$c7 $kern $c6
|
||||
wm $white-$c7 $wm $c4
|
||||
res $white-$c7 $res $c6
|
||||
shell $white-$c7 $shell $c4
|
||||
uptime $white-$c7 $days $hours $minutes $c6
|
||||
bat $white-$c7 ${bats[*]} $c4
|
||||
pkgs $white-$c7 $pkgs_total (AUR: $pkgs_aur) $c6
|
||||
wifi $white-$c7 $wifi_quality
|
||||
|
||||
EOF
|
41
fortuneprint.sh
Executable file
41
fortuneprint.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
PRINTLEN=42
|
||||
|
||||
LNBREAK=$(awk -v count=$PRINTLEN 'BEGIN { OFS="~"; $(count+1)="";print}')
|
||||
|
||||
cut () {
|
||||
python-escpos cut
|
||||
}
|
||||
|
||||
setnorms () {
|
||||
python-escpos set --align "left" --font "left" --text_type "NORMAL" \
|
||||
--height 1 --width 1 --density 1
|
||||
}
|
||||
|
||||
bold () {
|
||||
python-escpos set --align "center" --font "left" --text_type "B" \
|
||||
--height 1 --width 1 --density 3
|
||||
}
|
||||
|
||||
|
||||
for file in "$@"
|
||||
do
|
||||
FORTUNE=$(fortune -sn $PRINTLEN)
|
||||
bold
|
||||
python-escpos text --txt "$FORTUNE"
|
||||
python-escpos text --txt $LNBREAK
|
||||
for ln in $(cat $file)
|
||||
do
|
||||
python-escpos set --align "left" --font "center" --text_type "NORMAL" --height 1 --width 1 --density 1
|
||||
python-escpos text --txt "$ln"
|
||||
done
|
||||
bold
|
||||
python-escpos text --txt $LNBREAK
|
||||
python-escpos cut
|
||||
|
||||
done
|
||||
|
||||
setnorms
|
|
@ -1,10 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Polybar doesn't like it when you do stuff.
|
||||
|
||||
loop() {
|
||||
while true ; do
|
||||
OUTPUT=$(newsboat -x $1)
|
||||
OUTPUT=$(newsboat -x reload)
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
echo $OUTPUT
|
||||
|
@ -14,11 +12,22 @@ loop() {
|
|||
done
|
||||
}
|
||||
|
||||
check() {
|
||||
OUTPUT=$(newsboat -x print-unread)
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
echo $OUTPUT | sed 's/ .*/ articles/;s/^/ /'
|
||||
break
|
||||
else
|
||||
echo " ..."
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
update|up)
|
||||
loop reload
|
||||
loop
|
||||
;;
|
||||
fetch|fe)
|
||||
loop print-unread | sed 's/ .*/ articles/;s/^/ /'
|
||||
check
|
||||
;;
|
||||
esac
|
||||
|
|
3
get_wifi.sh
Normal file
3
get_wifi.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
awk '/wlan0/{ gsub(/\./,""); print $3; }' /proc/net/wireless
|
26
pdf_to_screenshot.sh
Executable file
26
pdf_to_screenshot.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
QUTEIN=/tmp/qutecap.pdf
|
||||
FILETYPE=png
|
||||
QUTEOUT=/tmp/qutecap.png
|
||||
|
||||
# 200 results in a large file already.
|
||||
DENSITY=200
|
||||
|
||||
if [ -f "$QUTEIN" ]; then
|
||||
if [ -f "$QUTEOUT" ]; then
|
||||
echo "Removing prev quteout"
|
||||
rm $QUTEOUT
|
||||
fi
|
||||
|
||||
touch $QUTEOUT
|
||||
|
||||
# Convert Qutebrowser PDF to selected filetype
|
||||
convert -density $DENSITY $QUTEIN -append $QUTEOUT
|
||||
|
||||
# Cleanup and move to screenshot
|
||||
mv $QUTEOUT ~/Captures/$(date '+%F_%H%M%S').png
|
||||
|
||||
# Cleanup
|
||||
rm $QUTEIN
|
||||
fi
|
||||
|
2
q11k.sh
2
q11k.sh
|
@ -3,7 +3,7 @@
|
|||
# configurations for each program.
|
||||
# Tablet info
|
||||
tablet="HID 256c:006e Pad pad"
|
||||
pen="HID 256c:006e Pen stylus"
|
||||
pen="HID 256c:006e stylus"
|
||||
|
||||
|
||||
# Set size stuff according to screen.
|
||||
|
|
11
tz.sh
Executable file
11
tz.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo -e "Timezone listing"
|
||||
|
||||
for zone in 'America/New_York' 'Asia/Hong_Kong' 'America/Mexico_City' 'Europe/London'
|
||||
do
|
||||
out=$(echo $zone | sed 's/.*\///;s/_/ /')
|
||||
real_time=$(TZ=$zone date "+$out (%:z) \033[32;1m%R\033[0m %F")
|
||||
echo -e $real_time
|
||||
done
|
||||
|
86
xon.py
Executable file
86
xon.py
Executable file
|
@ -0,0 +1,86 @@
|
|||
#!/bin/python3
|
||||
|
||||
# AGPLv3
|
||||
# Created by smolsheep
|
||||
# Please don't flood the API.
|
||||
|
||||
import json, http.client
|
||||
from urllib import request
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
|
||||
# Link to get json from
|
||||
xon_api = "https://xonotic.lifeisabug.com/endpoint/json"
|
||||
|
||||
# Create table
|
||||
console = Console()
|
||||
servlist = Table(show_header=True, header_style="bold cyan")
|
||||
servlist.add_column("", justify="right", min_width=6)
|
||||
servlist.add_column("Server", justify="left", min_width=72)
|
||||
servlist.add_column("Mode", justify="center", min_width=6)
|
||||
servlist.add_column("Map", justify="center", min_width=24)
|
||||
servlist.add_column("Count", justify="right", min_width=6)
|
||||
servlist.add_column("IP", justify="left", min_width=24)
|
||||
|
||||
# Request json from xon_api
|
||||
try:
|
||||
response = request.urlopen(xon_api)
|
||||
rawdata = response.read()
|
||||
except http.client.IncompleteRead as r:
|
||||
# This seems to always trigger.
|
||||
rawdata = r.partial
|
||||
|
||||
# Restructure locally before sorting
|
||||
data = json.loads(rawdata)
|
||||
unsorted = {}
|
||||
for rserv in data["server"]:
|
||||
srv = data["server"][rserv]
|
||||
if 0 < srv["numplayers"]:
|
||||
unsorted[srv["name"]] = {
|
||||
"num": srv["numplayers"],
|
||||
"max": srv["maxplayers"],
|
||||
"name": srv["realname"],
|
||||
"location": srv["geo"],
|
||||
"modes": {0:srv["mode"], 1:srv["mode2"]},
|
||||
"map": srv["map"],
|
||||
"ip": srv["address"]
|
||||
}
|
||||
|
||||
# Sort by number of players
|
||||
sorted = dict(sorted(unsorted.items(), key=lambda pcount: pcount[1]["num"], reverse=True))
|
||||
|
||||
# Fill out table and do operations to colorize the data
|
||||
for server in sorted:
|
||||
s = sorted[server]
|
||||
num= s["num"]
|
||||
max = s["max"]
|
||||
if max == num:
|
||||
s["countstr"] = f"[bold bright_red]{num}[/bold bright_red]"
|
||||
if (max/3) < num :
|
||||
s["countstr"] = f"[bold green]{num}[/bold green]"
|
||||
else:
|
||||
s["countstr"] = f"{num}"
|
||||
|
||||
main = s["modes"][0]
|
||||
min = s["modes"][1]
|
||||
if "DUEL" == s["modes"][0]:
|
||||
modecolor = "bright_red"
|
||||
s["modestr"] = f"[bold {modecolor}]{main}[/bold {modecolor}]"
|
||||
elif "CA" == s["modes"][0]:
|
||||
modecolor = "bright_cyan"
|
||||
s["modestr"] = f"[bold {modecolor}]{main}[/bold {modecolor}]"
|
||||
else:
|
||||
modecolor = "dark_white"
|
||||
s["modestr"] = f"[bold {modecolor}]{main}[/bold {modecolor}]"
|
||||
|
||||
servlist.add_row(
|
||||
s["location"],
|
||||
s["name"],
|
||||
s["modestr"],
|
||||
s["map"],
|
||||
s["countstr"],
|
||||
s["ip"]
|
||||
)
|
||||
|
||||
console.clear()
|
||||
console.print(servlist)
|
Loading…
Reference in a new issue