add:mangowm stuff

This commit is contained in:
kokopi-dev
2026-04-05 01:14:21 +09:00
parent 6fd4c54ded
commit e78e9b25f1
5 changed files with 101 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
# Personal Scripts Collection # Personal Scripts Collection
Collection of scripts I use frequently Collection of scripts I use frequently. Some of these are tailored specific to my env.
## Complementary Tool ## Complementary Tool

3
mangowm/README.md Normal file
View File

@@ -0,0 +1,3 @@
brightness.py: changes brightness of laptop monitor for framework 13 AMD
sc.sh: record a video of selection of the screen
ss.sh: screenshot a selection or full area of the screen

77
mangowm/brightness.py Executable file
View 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)

3
mangowm/sc.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/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
# 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 wl-screenrec -g "$GEOMETRY" -f ~/videos/recording-$(date +"%Y-%m-%d_%H-%M-%S").mp4 & fi; fi

17
mangowm/ss.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
MODE=${1:-area}
OUTPUT=~/pictures/$(date +"%Y-%m-%d_%H-%M-%S").png
case "$MODE" in
area)
grim -g "$(slurp)" - | satty --filename - --output-filename "$OUTPUT" --early-exit --copy-command wl-copy
;;
screen)
grim -g "$(slurp -o)" - | satty --filename - --output-filename "$OUTPUT" --early-exit --copy-command wl-copy
;;
*)
echo "Usage: $0 [area|screen]"
exit 1
;;
esac