mirror of
https://github.com/Fluffy-Bean/dots.git
synced 2025-06-03 00:43:12 +00:00
I hate this
This commit is contained in:
parent
a9846b4ecd
commit
8c7569868d
416 changed files with 1549 additions and 208 deletions
11
configs/eww/scripts/bluetooth
Executable file
11
configs/eww/scripts/bluetooth
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]; then
|
||||
echo "0"
|
||||
else
|
||||
if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ]; then
|
||||
echo "1"
|
||||
else
|
||||
echo "2"
|
||||
fi
|
||||
fi
|
62
configs/eww/scripts/homeassistant
Executable file
62
configs/eww/scripts/homeassistant
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from requests import get, post
|
||||
import sys
|
||||
import dotenv
|
||||
|
||||
url = dotenv.get_key('/home/fluffy/.config/eww/scripts/.env', 'HA_URL')
|
||||
bearer = dotenv.get_key('/home/fluffy/.config/eww/scripts/.env', 'HA_API')
|
||||
|
||||
def getStates(device):
|
||||
headers = {
|
||||
'Authorization': 'Bearer '+bearer,
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
|
||||
response = get(
|
||||
url+'/api/states/'+device,
|
||||
headers=headers
|
||||
)
|
||||
|
||||
if response.status_code == 200 or response.status_code == 201:
|
||||
return response.json()
|
||||
else:
|
||||
return False
|
||||
|
||||
def setState(device, state, value):
|
||||
headers = {
|
||||
'Authorization': 'Bearer '+bearer,
|
||||
'content-type': 'application/json',
|
||||
}
|
||||
|
||||
request = post(
|
||||
url+'/api/services/scene/apply',
|
||||
headers=headers,
|
||||
json={
|
||||
"entities": {
|
||||
device: {
|
||||
'state': 'on',
|
||||
state: value,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if request.status_code == 200 or request.status_code == 201:
|
||||
return request
|
||||
else:
|
||||
return False
|
||||
|
||||
if sys.argv[1] == "state":
|
||||
state = getStates('light.light')
|
||||
|
||||
if state:
|
||||
print(state['state'])
|
||||
elif sys.argv[1] == "toggle":
|
||||
state = getStates('light.light')
|
||||
|
||||
if state:
|
||||
if state['state'] == 'on':
|
||||
setState('light.light', 'state', 'off')
|
||||
else:
|
||||
setState('light.light', 'state', 'on')
|
12
configs/eww/scripts/light
Executable file
12
configs/eww/scripts/light
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Get power state
|
||||
get_state=$(curl -s "http://192.168.0.8/cm?cmnd=Status")
|
||||
state=$(echo $get_state | python3 -c "import sys, json; print(json.load(sys.stdin)['Status']['Power'])")
|
||||
|
||||
if [ $state -eq 1 ]; then
|
||||
echo "ON";
|
||||
else
|
||||
echo "OFF";
|
||||
fi
|
||||
|
24
configs/eww/scripts/powermenu
Executable file
24
configs/eww/scripts/powermenu
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
rofi_command="rofi -theme ~/.config/rofi/power.rasi -hover-select"
|
||||
uptime=$(uptime -p | sed -e 's/up //g')
|
||||
|
||||
# Options
|
||||
shutdown="Shutdown"
|
||||
reboot="Restart"
|
||||
lock="Lock"
|
||||
|
||||
options="$reboot\n$shutdown\n$lock"
|
||||
|
||||
chosen="$(echo -e "$options" | $rofi_command -p "Uptime: $uptime" -dmenu -selected-row 0)"
|
||||
case $chosen in
|
||||
$shutdown)
|
||||
systemctl poweroff
|
||||
;;
|
||||
$reboot)
|
||||
systemctl reboot
|
||||
;;
|
||||
$lock)
|
||||
dm-tool lock
|
||||
;;
|
||||
esac
|
8
configs/eww/scripts/toggle_bluetooth
Executable file
8
configs/eww/scripts/toggle_bluetooth
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
|
||||
then
|
||||
bluetoothctl power on
|
||||
else
|
||||
bluetoothctl power off
|
||||
fi
|
47
configs/eww/scripts/vpn
Executable file
47
configs/eww/scripts/vpn
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import dotenv
|
||||
|
||||
def getSession():
|
||||
list = subprocess.run(["openvpn3", "sessions-list"], capture_output=True)
|
||||
|
||||
if list.returncode != 0:
|
||||
return None
|
||||
|
||||
list_parsed = list.stdout.decode("utf-8").splitlines() # parse output to lines
|
||||
list_parsed = list_parsed[1] # get 2nd line
|
||||
list_parsed = list_parsed.split(":") # split line to list
|
||||
list_parsed = list_parsed[1].strip() # get second element and strip whitespaces
|
||||
|
||||
return list_parsed
|
||||
|
||||
def isConnected():
|
||||
list = subprocess.run(["openvpn3", "sessions-list"], capture_output=True)
|
||||
|
||||
if list.returncode != 0:
|
||||
return False
|
||||
elif len(list.stdout.decode("utf-8").splitlines()) < 6:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def toggle():
|
||||
if isConnected():
|
||||
session = getSession()
|
||||
subprocess.run(["openvpn3", "session-manage", "--disconnect", "--session-path", session], capture_output=True)
|
||||
else:
|
||||
config = dotenv.get_key('/home/fluffy/.config/eww/scripts/.env', 'VPN_PATH')
|
||||
subprocess.run(["openvpn3", "session-start", "--config", config], capture_output=True)
|
||||
|
||||
try:
|
||||
if sys.argv[1] == "status":
|
||||
if isConnected():
|
||||
print (1)
|
||||
else:
|
||||
print(0)
|
||||
elif sys.argv[1] == "toggle":
|
||||
toggle()
|
||||
except:
|
||||
print("No arguments given")
|
27
configs/eww/scripts/workspaces
Executable file
27
configs/eww/scripts/workspaces
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
gib() {
|
||||
current=$(wmctrl -d | grep '*' | awk '{print $1}')
|
||||
|
||||
for workspace in $(wmctrl -d | awk '{print $1}'); do
|
||||
if [ $current -eq $workspace ]; then
|
||||
focused="workspace-focused"
|
||||
else
|
||||
focused=""
|
||||
fi
|
||||
|
||||
if [ $(wmctrl -lx | grep " $workspace " | awk '{print $1}' | wc -l) -gt 0 ]; then
|
||||
occupied="workspace-occupied"
|
||||
else
|
||||
occupied=""
|
||||
fi
|
||||
|
||||
echo "(button :class \"workspace $occupied $focused\" :onclick \"wmctrl -s $workspace\")"
|
||||
done
|
||||
}
|
||||
|
||||
# echo "(box :class \"workspaces\" :orientation \"v\" :space-evenly false :spacing \"0\" $(gib))"
|
||||
|
||||
xprop -spy -root _NET_CURRENT_DESKTOP | while read -r; do
|
||||
eww update workspace_data="(box :class \"workspaces\" :orientation \"v\" :space-evenly false :spacing \"0\" $(gib))"
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue