Updated dotfiles
This commit is contained in:
parent
0a6995de56
commit
9c416de308
31 changed files with 641 additions and 106 deletions
7
sketchybar/plugins/cpu.sh
Executable file
7
sketchybar/plugins/cpu.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
cpu_percent=$(top -l 2 | grep -E "^CPU" | tail -1 | awk '{ print $3 + $5"%" }')
|
||||
|
||||
sketchybar --set $NAME icon= label="${cpu_percent}"
|
||||
|
||||
|
5
sketchybar/plugins/memory.sh
Executable file
5
sketchybar/plugins/memory.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
MEMORY=$(memory_pressure | tail -n 1 | awk '{print $5}')
|
||||
|
||||
sketchybar --set $NAME icon= label="${MEMORY}"
|
BIN
sketchybar/plugins/temp_sensor
Executable file
BIN
sketchybar/plugins/temp_sensor
Executable file
Binary file not shown.
|
@ -1,28 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
|
||||
CHARGING=$(pmset -g batt | grep 'AC Power')
|
||||
|
||||
if [ $PERCENTAGE = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case ${PERCENTAGE} in
|
||||
9[0-9]|100) ICON=""
|
||||
;;
|
||||
[6-8][0-9]) ICON=""
|
||||
;;
|
||||
[3-5][0-9]) ICON=""
|
||||
;;
|
||||
[1-2][0-9]) ICON=""
|
||||
;;
|
||||
*) ICON=""
|
||||
esac
|
||||
|
||||
if [[ $CHARGING != "" ]]; then
|
||||
ICON=""
|
||||
fi
|
||||
TEMP=$(~/.config/sketchybar/plugins/temp_sensor)
|
||||
|
||||
# The item invoking this script (name $NAME) will get its icon and label
|
||||
# updated with the current battery status
|
||||
sketchybar --set $NAME icon="$ICON" label="${PERCENTAGE}%"
|
||||
sketchybar --set $NAME icon= label="${TEMP}°"
|
||||
|
|
11
sketchybar/plugins/wifi.sh
Executable file
11
sketchybar/plugins/wifi.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
CURRENT_WIFI="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I)"
|
||||
SSID="$(echo "$CURRENT_WIFI" | grep -o "SSID: .*" | sed 's/^SSID: //')"
|
||||
|
||||
|
||||
if [ "$SSID" = "" ]; then
|
||||
sketchybar --set $NAME icon= label="DISC"
|
||||
else
|
||||
sketchybar --set $NAME icon= label="CONN"
|
||||
fi
|
48
sketchybar/plugins/windows.py
Executable file
48
sketchybar/plugins/windows.py
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/opt/homebrew/bin/python3
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
def get_current_space_index():
|
||||
space_obj = json.loads(os.popen("yabai -m query --spaces --space").read())
|
||||
return space_obj["index"]
|
||||
|
||||
def get_space_windows(idx):
|
||||
windows_obj = json.loads(os.popen("yabai -m query --windows --space "+str(idx)).read())
|
||||
return windows_obj
|
||||
|
||||
def clear_sketchybar_items_string():
|
||||
bar_obj = json.loads(os.popen("sketchybar --query bar").read())
|
||||
bar_items = bar_obj["items"]
|
||||
cmd = ""
|
||||
for item in bar_items:
|
||||
if item == "window_handler":
|
||||
continue
|
||||
cmd+=" --remove "+item
|
||||
return cmd
|
||||
|
||||
|
||||
def add_sketchybar_items(windows):
|
||||
cmd = "sketchybar " + clear_sketchybar_items_string()
|
||||
for i,w in enumerate(windows):
|
||||
title = (w["title"][:28] + '..') if len(w["title"]) > 30 else w["title"]
|
||||
cmd+=" --add item window_"+str(i)+" left"
|
||||
cmd+=" --set window_"+str(i)+" label='"+title+"'"
|
||||
cmd+=" click_script='yabai -m window --focus "+str(w["id"])+"'"
|
||||
if w["has-focus"]:
|
||||
cmd+=" label.color=0xff7ed321"
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
idx=get_current_space_index()
|
||||
windows = get_space_windows(idx)
|
||||
#windows = sorted(windows,key=lambda x: x["id"])
|
||||
|
||||
print("---")
|
||||
add_sketchybar_items(windows)
|
||||
print("---")
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue