This commit is contained in:
sankalp committed 2025-01-11 08:03:49 +05:45
1 parent 18e38a9f61
commit 54d6afbb44
60 files changed
+12 -9

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
get() {
cliphist list | iconv -f $(locale charmap) -t UTF-8 -c
}
copy_by_id() {
id=$1
cliphist decode $id | wl-copy
}
clear() {
cliphist wipe
}
save_cache_file() {
id=$1
output_file="/tmp/ags/cliphist/$id.png"
if [[ ! -f "$output_file" ]]; then
mkdir -p "/tmp/ags/cliphist/"
cliphist decode "$id" >"$output_file"
fi
echo $output_file
}
clear_tmp() {
rm "/tmp/ags/cliphist/*"
}
if [[ "$1" == "--get" ]]; then
get
elif [[ "$1" == "--copy-by-id" ]]; then
{ copy_by_id "$2"; }
elif [[ "$1" == "--save-by-id" ]]; then
{ save_cache_file "$2"; }
elif [[ "$1" == "--clear-cache" ]]; then
clear_tmp
elif [[ "$1" == "--clear" ]]; then
clear
fi
+49
View File
@@ -0,0 +1,49 @@
#!/bin/bash
GENERATOR="$HOME/dotfiles/material-colors/generate.py"
SETTINGS_FILE="$HOME/dotfiles/.settings/settings.json"
# Function to read a value from the JSON file
get_json_value() {
local key=$1
jq -r --arg key "$key" '.[$key]' $SETTINGS_FILE
}
# Function to update a value in the JSON file
update_json_value() {
local key=$1
local value=$2
jq --arg key "$key" --arg value "$value" \
'.[$key] = $value' $SETTINGS_FILE > "$SETTINGS_FILE.tmp" && mv "$SETTINGS_FILE.tmp" $SETTINGS_FILE
}
toggle() {
local color_scheme=$(get_json_value "color-scheme")
local generation_scheme=$(get_json_value "generation-scheme")
if [ "$color_scheme" == "dark" ]; then
python -O $GENERATOR -R --color-scheme light --scheme $generation_scheme
update_json_value "color-scheme" "light"
elif [ "$color_scheme" == "light" ]; then
python -O $GENERATOR -R --color-scheme dark --scheme $generation_scheme
update_json_value "color-scheme" "dark"
else
echo "Unknown color scheme: $color_scheme"
fi
}
set() {
local new_scheme=$1
local generation_scheme=$(get_json_value "generation-scheme")
python -O $GENERATOR -R --color-scheme $new_scheme --scheme $generation_scheme
update_json_value "color-scheme" $new_scheme
}
# Process arguments
if [[ "$1" == "--toggle" ]]; then
toggle
elif [[ "$1" == "--set" ]]; then
set $2
else
echo "Usage: $0 --toggle | --set <color-scheme>"
fi
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env python
import sys
from dataclasses import dataclass
from signal import SIGINT, SIGTERM, signal
from threading import Event
import setproctitle
from pywayland.client.display import Display # type: ignore
from pywayland.protocol.idle_inhibit_unstable_v1.zwp_idle_inhibit_manager_v1 import ( # type: ignore
ZwpIdleInhibitManagerV1,
)
from pywayland.protocol.wayland.wl_compositor import WlCompositor # type: ignore
from pywayland.protocol.wayland.wl_registry import WlRegistryProxy # type: ignore
from pywayland.protocol.wayland.wl_surface import WlSurface # type: ignore
@dataclass
class GlobalRegistry:
surface: WlSurface | None = None
inhibit_manager: ZwpIdleInhibitManagerV1 | None = None
def handle_registry_global(
wl_registry: WlRegistryProxy, id_num: int, iface_name: str, version: int
) -> None:
global_registry: GlobalRegistry = wl_registry.user_data or GlobalRegistry()
if iface_name == "wl_compositor":
compositor = wl_registry.bind(id_num, WlCompositor, version)
global_registry.surface = compositor.create_surface() # type: ignore
elif iface_name == "zwp_idle_inhibit_manager_v1":
global_registry.inhibit_manager = wl_registry.bind(
id_num, ZwpIdleInhibitManagerV1, version
)
def main() -> None:
done = Event()
signal(SIGINT, lambda _, __: done.set())
signal(SIGTERM, lambda _, __: done.set())
global_registry = GlobalRegistry()
display = Display()
display.connect()
registry = display.get_registry() # type: ignore
registry.user_data = global_registry
registry.dispatcher["global"] = handle_registry_global
def shutdown() -> None:
display.dispatch()
display.roundtrip()
display.disconnect()
display.dispatch()
display.roundtrip()
if global_registry.surface is None or global_registry.inhibit_manager is None:
print("Wayland seems not to support idle_inhibit_unstable_v1 protocol.")
shutdown()
sys.exit(1)
inhibitor = global_registry.inhibit_manager.create_inhibitor( # type: ignore
global_registry.surface
)
display.dispatch()
display.roundtrip()
print("Inhibiting idle...")
done.wait()
print("Shutting down...")
inhibitor.destroy()
shutdown()
if __name__ == "__main__":
setproctitle.setproctitle("wayland-idle-inhibitor.py")
main()