Laptop files
This commit is contained in:
BIN
eww/scripts/.cache.sqlite
Normal file
BIN
eww/scripts/.cache.sqlite
Normal file
Binary file not shown.
10
eww/scripts/audio.sh
Executable file
10
eww/scripts/audio.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
MASTER_STATE=$(amixer sget Master | grep -Po "(?<=\[)(on)|(off)(?=\])" | head -n1)
|
||||
|
||||
if [ $MASTER_STATE = "off" ]
|
||||
then
|
||||
echo 0
|
||||
else
|
||||
echo $(amixer sget Master | grep -Po "(?<=\[)[[:digit:]]+(?=(%\]))" | head -n1)
|
||||
fi
|
5
eww/scripts/change_active_workspace.sh
Executable file
5
eww/scripts/change_active_workspace.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#! /bin/bash
|
||||
workspace=$1
|
||||
|
||||
echo "Switching to workspace $workspace"
|
||||
hyprctl dispatch workspace $workspace
|
3
eww/scripts/cpu_usage.sh
Executable file
3
eww/scripts/cpu_usage.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1""}')"
|
3
eww/scripts/flatpak_updates.sh
Executable file
3
eww/scripts/flatpak_updates.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "$(flatpak update | grep -P '[[:digit:]]+\.' | awk '{sum = sum + 1 } END { print sum }')"
|
3
eww/scripts/get_active_workspace.sh
Executable file
3
eww/scripts/get_active_workspace.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
hyprctl monitors -j | jq --raw-output .[0].activeWorkspace.id
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^workspace>>/{print $2}'
|
11
eww/scripts/get_workspaces.sh
Executable file
11
eww/scripts/get_workspaces.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
spaces (){
|
||||
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
|
||||
seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
|
||||
}
|
||||
|
||||
spaces
|
||||
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
|
||||
spaces
|
||||
done
|
2
eww/scripts/lock.sh
Executable file
2
eww/scripts/lock.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
swaylock -c 000000
|
11
eww/scripts/network.sh
Executable file
11
eww/scripts/network.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
net_status () {
|
||||
if (ping -c 1 google.com || ping -c 1 archlinux.org || ping -c 1 github.com) &> /dev/null; then
|
||||
echo true;
|
||||
else
|
||||
echo false;
|
||||
fi
|
||||
}
|
||||
|
||||
net_status
|
3
eww/scripts/ram_usage.sh
Executable file
3
eww/scripts/ram_usage.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
free -m | awk 'NR==2{printf "%.2f\n", $3*100/$2 }'
|
16
eww/scripts/rx_bandwidth.sh
Executable file
16
eww/scripts/rx_bandwidth.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
DEV=`nmcli d | grep -P "[^(dis)]connected [^(\(externally\))]" | grep -Po ".*?(?= )" | head -n1`
|
||||
RX_BYTES=`cat /sys/class/net/$DEV/statistics/rx_bytes`
|
||||
|
||||
RX_KB=`expr $RX_BYTES / 1024`
|
||||
RX_MB=`expr $RX_KB / 1024`
|
||||
|
||||
if [ $RX_MB -ge 1 ]
|
||||
then
|
||||
echo $RX_MB mB/s
|
||||
elif [ $RX_KB >= 1 ]
|
||||
then
|
||||
echo $RX_KB kB/s
|
||||
else
|
||||
echo $RX_BYTES B/s
|
||||
fi
|
2
eww/scripts/speakerstate.sh
Executable file
2
eww/scripts/speakerstate.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
amixer sget Master | grep -Po '(?<=\[)off(?=\])' | head -n1
|
17
eww/scripts/tx_bandwidth.sh
Executable file
17
eww/scripts/tx_bandwidth.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
DEV=`nmcli d | grep -P "[^(dis)]connected [^(\(externally\))]" | grep -Po ".*?(?= )" | head -n1`
|
||||
TX_BYTES=$(cat /sys/class/net/$DEV/statistics/tx_bytes)
|
||||
|
||||
TX_KB=`expr $TX_BYTES / 1024`
|
||||
TX_MB=`expr $TX_KB / 1024`
|
||||
|
||||
|
||||
if [ $TX_MB -ge 1 ]
|
||||
then
|
||||
echo $TX_MB mB/s
|
||||
elif [ $TX_KB -ge 1 ]
|
||||
then
|
||||
echo $TX_KB kB/s
|
||||
else
|
||||
echo $TX_BYTES B/s
|
||||
fi
|
76
eww/scripts/weather.py
Normal file
76
eww/scripts/weather.py
Normal file
@ -0,0 +1,76 @@
|
||||
import openmeteo_requests
|
||||
import requests_cache
|
||||
from retry_requests import retry
|
||||
import requests
|
||||
import sys
|
||||
|
||||
conditions = {
|
||||
0: "",
|
||||
1: "",
|
||||
2: "",
|
||||
3: "",
|
||||
45: "",
|
||||
48: "",
|
||||
51: "",
|
||||
53: "",
|
||||
55: "",
|
||||
61: "",
|
||||
63: "",
|
||||
65: "",
|
||||
71: "",
|
||||
73: "",
|
||||
75: "",
|
||||
95: "",
|
||||
96: "",
|
||||
99: "",
|
||||
}
|
||||
|
||||
latitude, longitude = eval(requests.get("https://ipinfo.io/loc").text)
|
||||
city = requests.get("https://ipinfo.io/city").text.strip()
|
||||
|
||||
cache_session = requests_cache.CachedSession('.cache', expire_after=3600)
|
||||
retry_session = retry(cache_session, retries=5, backoff_factor = 0.2)
|
||||
openmeteo = openmeteo_requests.Client(session = retry_session)
|
||||
|
||||
url = "https://api.open-meteo.com/v1/forecast"
|
||||
params = {
|
||||
"latitude": latitude,
|
||||
"longitude": longitude,
|
||||
"current": ["is_day", "weather_code", "temperature_2m"],
|
||||
"temperature_unit": "fahrenheit",
|
||||
"wind_speed_unit": "mph",
|
||||
"precipitation_unit": "inch"
|
||||
}
|
||||
|
||||
responses = openmeteo.weather_api(url, params=params)
|
||||
response = responses[0]
|
||||
|
||||
current = response.Current()
|
||||
current_is_day = bool(current.Variables(0).Value())
|
||||
current_weather_code = int(current.Variables(1).Value())
|
||||
current_temperature = int(current.Variables(2).Value())
|
||||
|
||||
print(f"{city} {conditions[current_weather_code]} {current_temperature}°F")
|
||||
|
||||
|
||||
#try:
|
||||
#location_info = weather_json["properties"]["relativeLocation"]["properties"]
|
||||
#except KeyError:
|
||||
#if weather_json["status"] == 404:
|
||||
#print("NOAA only supports U.S. locations")
|
||||
|
||||
#city = location_info["city"]
|
||||
#state = location_info["state"]
|
||||
|
||||
#forecast_url = weather_json["properties"]["forecast"]
|
||||
#forecast_json = requests.get(forecast_url).json()
|
||||
|
||||
#current_forecast = forecast_json["properties"]["periods"][0]
|
||||
#temperature = current_forecast["temperature"]
|
||||
#temperature_units = current_forecast["temperatureUnit"]
|
||||
#short_forecast = current_forecast["shortForecast"]
|
||||
|
||||
#try:
|
||||
#print(f"{city}, {state} {conditions[short_forecast]} {temperature}°{temperature_units}")
|
||||
#except KeyError:
|
||||
#print(f"{city}, {state} {short_forecast} {temperature}°{temperature_units}")
|
8
eww/scripts/workspace_class.sh
Executable file
8
eww/scripts/workspace_class.sh
Executable file
@ -0,0 +1,8 @@
|
||||
ACTIVE=$(hyprctl activeworkspace | grep -Po '(?<=ID )[[:digit:]]')
|
||||
|
||||
if [ $ACTIVE -eq $1 ]
|
||||
then
|
||||
echo "active_workspace"
|
||||
else
|
||||
echo "inactive_workspace"
|
||||
fi
|
42
eww/scripts/workspaces.sh
Executable file
42
eww/scripts/workspaces.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Checks if a list ($1) contains an element ($2)
|
||||
contains() {
|
||||
for e in $1; do
|
||||
[[ "$e" -eq "$2" ]] && echo 1 && return
|
||||
done
|
||||
echo 0
|
||||
}
|
||||
|
||||
print_workspaces() {
|
||||
local buf=""
|
||||
local desktops=$(bspc query -D --names)
|
||||
local focused_desktop=$(bspc query -D -d focused --names)
|
||||
local occupied_desktops=$(bspc query -D -d .occupied --names)
|
||||
|
||||
for d in $desktops; do
|
||||
if [[ "$(contains "$focused_desktop" "$d")" -eq 1 ]]; then
|
||||
local ws=$d
|
||||
local icon=""
|
||||
local class="workspace-focused"
|
||||
elif [[ "$(contains "$occupied_desktops" "$d")" -eq 1 ]]; then
|
||||
local ws=$d
|
||||
local icon=""
|
||||
local class="workspace-occupied"
|
||||
else
|
||||
local ws="$d"
|
||||
local icon=""
|
||||
local class="workspace-empty"
|
||||
fi
|
||||
|
||||
local buf+="(eventbox :cursor \"pointer\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"$icon\"))"
|
||||
done
|
||||
|
||||
echo "(box :orientation \"h\" :class \"works\" :halign \"center\" :halign \"center\" :hexpand true :vexpand true $buf)"
|
||||
}
|
||||
|
||||
# Listen to bspwm changes
|
||||
print_workspaces
|
||||
bspc subscribe desktop node_transfer | while read -r _; do
|
||||
print_workspaces &
|
||||
done
|
Reference in New Issue
Block a user