add:wip mango
This commit is contained in:
77
mango/local-bin/brightness.py
Executable file
77
mango/local-bin/brightness.py
Executable file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
|
||||
class AMDVideo:
|
||||
_brightness_filepath: Path = Path("/sys/class/backlight/amdgpu_bl1/brightness")
|
||||
_max_brightness_filepath: Path = Path("/sys/class/backlight/amdgpu_bl1/max_brightness")
|
||||
|
||||
brightness: int|None
|
||||
max_brightness: int|None
|
||||
|
||||
def __init__(self):
|
||||
self.brightness = self._get_file_int_value(self._brightness_filepath)
|
||||
self.max_brightness = self._get_file_int_value(self._max_brightness_filepath)
|
||||
|
||||
def _get_file_int_value(self, filepath: Path) -> int:
|
||||
with filepath.open("r", encoding="utf-8") as f:
|
||||
return int(f.read().strip())
|
||||
|
||||
def _update_file_value(self, filepath: Path, value) -> None:
|
||||
with filepath.open("w+") as f:
|
||||
f.write(str(value))
|
||||
|
||||
def increase_brightness(self, inc_by: int|None = None):
|
||||
if not self.max_brightness:
|
||||
print(f"error: max_brightness file not found {self._max_brightness_filepath}")
|
||||
return
|
||||
if not self.brightness:
|
||||
print(f"error: brightness file not found {self._brightness_filepath}")
|
||||
return
|
||||
|
||||
if not inc_by:
|
||||
inc_by = int(self.max_brightness / 15)
|
||||
|
||||
new_val = self.brightness + inc_by
|
||||
if new_val > self.max_brightness:
|
||||
new_val = self.max_brightness
|
||||
|
||||
self._update_file_value(self._brightness_filepath, new_val)
|
||||
|
||||
def decrease_brightness(self, dec_by: int|None = None):
|
||||
if not self.max_brightness:
|
||||
return
|
||||
if not self.brightness:
|
||||
return
|
||||
|
||||
if not dec_by:
|
||||
dec_by = int(self.max_brightness / 15)
|
||||
|
||||
new_val = self.brightness - dec_by
|
||||
lowest_brightness = int(self.max_brightness * 0.05)
|
||||
if new_val < lowest_brightness:
|
||||
new_val = lowest_brightness
|
||||
|
||||
self._update_file_value(self._brightness_filepath, new_val)
|
||||
|
||||
def print_status(self):
|
||||
brightness = self._get_file_int_value(self._brightness_filepath)
|
||||
print(f"brightness: {brightness}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print("need argument +/-")
|
||||
exit(1)
|
||||
a = AMDVideo()
|
||||
if sys.argv[1] == "+":
|
||||
a.increase_brightness()
|
||||
if sys.argv[1] == "-":
|
||||
a.decrease_brightness()
|
||||
if sys.argv[1] == "status":
|
||||
a.print_status()
|
||||
|
||||
#
|
||||
# command = ""
|
||||
#
|
||||
# result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
6
mango/local-bin/init-lockscreen
Executable file
6
mango/local-bin/init-lockscreen
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
killall swayidle
|
||||
sleep 0.1
|
||||
swayidle -w \
|
||||
before-sleep 'swaylock -i ~/pictures/flower.jpg --effect-blur 7x5 --effect-vignette 0.5:0.5 --clock --indicator --ring-color E8D4A0FF --key-hl-color F4A261FF --bs-hl-color EE9B00FF --inside-color 00000088 --text-color FFFFFFFF --line-color 00000000 --separator-color 00000000' \
|
||||
lock 'swaylock -i ~/pictures/flower.jpg --effect-blur 7x5 --effect-vignette 0.5:0.5 --clock --indicator --ring-color E8D4A0FF --key-hl-color F4A261FF --bs-hl-color EE9B00FF --inside-color 00000088 --text-color FFFFFFFF --line-color 00000000 --separator-color 00000000' &
|
||||
2
mango/local-bin/init-screen-scale
Executable file
2
mango/local-bin/init-screen-scale
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
wlr-randr --output eDP-1 --scale 1.25
|
||||
2
mango/local-bin/run-lockscreen.sh
Executable file
2
mango/local-bin/run-lockscreen.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
swaylock -i ~/pictures/flower.jpg --effect-blur 7x5 --effect-vignette 0.5:0.5 --clock --indicator --ring-color E8D4A0FF --key-hl-color F4A261FF --bs-hl-color EE9B00FF --inside-color 00000088 --text-color FFFFFFFF --line-color 00000000 --separator-color 00000000
|
||||
163
mango/local-bin/run-wlsunset.sh
Executable file
163
mango/local-bin/run-wlsunset.sh
Executable file
@@ -0,0 +1,163 @@
|
||||
#!/bin/bash
|
||||
if ! command -v gum &> /dev/null; then
|
||||
echo "❌ Error: 'gum' is not installed."
|
||||
echo "Install with: go install github.com/charmbracelet/gum@latest"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v wlsunset &> /dev/null; then
|
||||
echo "❌ Error: 'wlsunset' is not installed."
|
||||
echo "Install with your package manager (e.g., pacman -S wlsunset)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LAT_LON_FILE="$HOME/.config/wlsunset/location"
|
||||
|
||||
PRIMARY="#cba6f7"
|
||||
SECONDARY="#89b4fa"
|
||||
SUCCESS="#a6e3a1"
|
||||
WARNING="#f9e2af"
|
||||
DANGER="#f38ba8"
|
||||
ACCENT="#f5c2e7"
|
||||
MUTED="#6c7086"
|
||||
|
||||
BTN_TOGGLE=" ╭─────────────────────────────╮
|
||||
│ Toggle │
|
||||
╰─────────────────────────────╯"
|
||||
BTN_FORCE=" ╭─────────────────────────────╮
|
||||
│ Force On │
|
||||
╰─────────────────────────────╯"
|
||||
BTN_CHANGE_LOC=" ╭─────────────────────────────╮
|
||||
│ Change Location │
|
||||
╰─────────────────────────────╯"
|
||||
BTN_CHANGE_STR=" ╭─────────────────────────────╮
|
||||
│ Change Strength │
|
||||
╰─────────────────────────────╯"
|
||||
BTN_EXIT=" ╭─────────────────────────────╮
|
||||
│ Exit │
|
||||
╰─────────────────────────────╯"
|
||||
|
||||
show_header() {
|
||||
TERM_WIDTH=$(tput cols)
|
||||
total_width=$((TERM_WIDTH - 2))
|
||||
# Main title box
|
||||
gum style \
|
||||
--foreground "$ACCENT" \
|
||||
--border-foreground "$ACCENT" \
|
||||
--border "rounded" \
|
||||
--width $total_width \
|
||||
--align "center" \
|
||||
--padding "2 0" \
|
||||
"🌅 NIGHT LIGHT 🌙"
|
||||
|
||||
echo ""
|
||||
|
||||
if pidof wlsunset > /dev/null; then
|
||||
status=" ACTIVE"
|
||||
foreground_color=$SUCCESS
|
||||
else
|
||||
status=" INACTIVE"
|
||||
foreground_color=$MUTED
|
||||
fi
|
||||
gum join --horizontal \
|
||||
"$(gum style --width $total_width --align "center" --foreground "$foreground_color" --padding "0 2" --margin "0 1" "$status")" \
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
get_status() {
|
||||
if pidof wlsunset > /dev/null; then
|
||||
echo " ACTIVE"
|
||||
else
|
||||
echo " INACTIVE"
|
||||
fi
|
||||
}
|
||||
|
||||
show_menu() {
|
||||
term_width=$(tput cols)
|
||||
button_width=33
|
||||
padding=$(( (term_width - button_width) / 2 ))
|
||||
pad_str=$(printf "%*s" $padding "")
|
||||
|
||||
# Pad each button using sed to add padding to every line
|
||||
padded_buttons=()
|
||||
for btn in "$BTN_TOGGLE" "$BTN_FORCE" "$BTN_CHANGE_LOC" "$BTN_CHANGE_STR" "$BTN_EXIT"; do
|
||||
padded_btn=$(echo "$btn" | sed "s/^/$pad_str/")
|
||||
padded_buttons+=("$padded_btn")
|
||||
done
|
||||
|
||||
choice=$(gum choose \
|
||||
--header "" \
|
||||
--cursor " " \
|
||||
--cursor.foreground "$PRIMARY" \
|
||||
--selected.foreground "$SUCCESS" \
|
||||
--item.foreground "$SECONDARY" \
|
||||
"${padded_buttons[@]}")
|
||||
|
||||
echo "$choice"
|
||||
}
|
||||
|
||||
if [ -f "$LAT_LON_FILE" ]; then
|
||||
source "$LAT_LON_FILE"
|
||||
else
|
||||
location=$(curl -s "https://ipinfo.io/loc")
|
||||
if [ ! -z "$location" ]; then
|
||||
LAT=$(echo "$location" | cut -d',' -f1)
|
||||
LON=$(echo "$location" | cut -d',' -f2)
|
||||
else
|
||||
# random default in LA
|
||||
LAT=34.0522
|
||||
LON=-118.2437
|
||||
fi
|
||||
echo -e "LAT=$LAT\nLON=$LON\nSTRENGTH=4750" > "$LAT_LON_FILE"
|
||||
fi
|
||||
|
||||
expand_terminal() {
|
||||
# launching via rofi doesnt expand terminal at start
|
||||
gum style --width 120 " " > /dev/null 2>&1 || true
|
||||
gum style --width 120 --foreground "#00000000" " "
|
||||
printf "\033[1A\033[K" # Move up and clear line
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"init")
|
||||
# turn on
|
||||
wlsunset -l $LAT -L $LON -t $STRENGTH
|
||||
;;
|
||||
*)
|
||||
expand_terminal
|
||||
show_header
|
||||
choice=$(show_menu)
|
||||
case "$choice" in
|
||||
*"Toggle"*)
|
||||
if pidof wlsunset > /dev/null; then
|
||||
if killall wlsunset; then
|
||||
gum style --foreground "$MUTED" "Disabled night light"
|
||||
notify-send "wlsunset" " Disabled night light"
|
||||
else
|
||||
notify-send "wlsunset" " Failed to disable night light"
|
||||
fi
|
||||
else
|
||||
setsid wlsunset -l "$LAT" -L "$LON" -t $STRENGTH & disown
|
||||
gum style --foreground "$SUCCESS" "Enabled night light"
|
||||
notify-send "wlsunset" " Enabled night light"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
*"Force"*)
|
||||
setsid wlsunset -s 00:00 -S 23:59 -t $STRENGTH & disown
|
||||
notify-send "wlsunset" " Force enabled night light"
|
||||
exit 0
|
||||
;;
|
||||
*"Exit"*)
|
||||
clear
|
||||
gum style --foreground "$MUTED" --align "center" "👋 Goodbye!"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo " choice not found"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
2
mango/local-bin/sc.sh
Executable file
2
mango/local-bin/sc.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
if pgrep -x wl-screenrec > /dev/null; then pkill -INT wl-screenrec && notify-send "🎥 Recording Stopped" "Saved to ~/videos"; else GEOMETRY=$(slurp); if [ -n "$GEOMETRY" ]; then notify-send "🎥 Recording Started" "Press Super+Alt+v to stop" && wl-screenrec -g "$GEOMETRY" -f ~/videos/recording-$(date +"%Y-%m-%d_%H-%M-%S").mp4 & fi; fi
|
||||
2
mango/local-bin/ss.sh
Executable file
2
mango/local-bin/ss.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
grim -g "$(slurp)" - | satty --filename - --output-filename ~/pictures/$(date +"%Y-%m-%d_%H-%M-%S").png --early-exit --copy-command wl-copy
|
||||
Reference in New Issue
Block a user