Add files via upload

This commit is contained in:
FURK4NGG
2026-01-29 01:19:22 +03:00
committed by GitHub
parent e6a7381297
commit 106062adb8
6 changed files with 232 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
# -------------------------
# Base paths (EN BAŞTA)
# -------------------------
BASE_DIR="$HOME/.config/blacklayer"
CONF_FILE="$BASE_DIR/blacklayer.conf"
[ -f "$CONF_FILE" ] && source "$CONF_FILE"
PID_FILE="$BASE_DIR/blacklayer_worker.pid"
STATE_DIR="$BASE_DIR/blacklayer_state"
COUNT_FILE="$BASE_DIR/blacklayer_count"
WORKER="$BASE_DIR/blacklayer-worker.sh"
BLACKLAYER_BIN="$BASE_DIR/blacklayer"
NEED_HYPRIDLE=false
if [ "$run_lock" = "true" ] || [ "$run_sleep" = "true" ]; then
NEED_HYPRIDLE=true
else
notify-send "Hypridle" "hypridle is disabled via config"
echo "[hypridle] disabled via config"
fi
HYPRIDLE_RUNNING=false
if systemctl --user --quiet is-active hypridle.service; then
HYPRIDLE_RUNNING=true
fi
case "$NEED_HYPRIDLE:$HYPRIDLE_RUNNING" in
true:false)
# Gerekli ama çalışmıyor → BAŞLAT
notify-send "Hypridle" "hypridle is enabled"
systemctl --user start hypridle.service
;;
true:true)
# Gerekli fakat çalışıyor → KAPAT
notify-send "Hypridle" "hypridle is disabled"
systemctl --user stop hypridle.service
;;
false:true)
# Gerekli değil fakat çalışıyor → KAPAT
#If you try to start hypridle.service and its closed by own this >
notify-send "Hypridle" "hypridle is disabled"
systemctl --user stop hypridle.service
;;
*)
;;
esac
# eğer blacklayer kapalıysa çık
if [ "$run_blacklayer" != "true" ]; then
notify-send "Blacklayer" "blacklayer is disabled via config"
echo "[blacklayer] disabled via config"
kill "$(cat "$PID_FILE")" 2>/dev/null
rm -f "$PID_FILE"
# Tüm blacklayer processlerini kapat
pkill -f "$BLACKLAYER_BIN" 2>/dev/null
# State & count temizliği
rm -rf "$STATE_DIR"
rm -f "$COUNT_FILE"
exit 0
fi
# Dizini garanti altına al
mkdir -p "$STATE_DIR"
# -------------------------
# Worker çalışıyorsa → KAPAT
# -------------------------
if [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
notify-send "Blacklayer" "blacklayer is stopping"
echo "[blacklayer] stopping..."
# Worker'ı kapat
kill "$(cat "$PID_FILE")" 2>/dev/null
rm -f "$PID_FILE"
# Tüm blacklayer processlerini kapat
pkill -f "$BLACKLAYER_BIN" 2>/dev/null
# State & count temizliği
rm -rf "$STATE_DIR"
rm -f "$COUNT_FILE"
exit 0
fi
# -------------------------
# Çalışmıyorsa → BAŞLAT
# -------------------------
notify-send "Blacklayer" "blacklayer is starting"
echo "[blacklayer] starting..."
nohup bash "$WORKER" >/dev/null 2>&1 &
echo $! > "$PID_FILE"
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Kullanım: event-driven.sh <MONITOR_NAME> <POLL_INTERVAL>
MONITOR="$1"
POLL_INTERVAL="${2:-3}" # default 3s
[ -z "$MONITOR" ] && { echo "Monitor arg missing"; exit 1; }
BASE_DIR="$HOME/.config/blacklayer"
BLACKLAYER_BIN="$BASE_DIR/blacklayer"
STATE_DIR="$BASE_DIR/.blacklayer_state"
STATE_FILE="$STATE_DIR/$MONITOR"
WAYBAR_BIN="/usr/bin/waybar"
WAYBAR_CONFIG_DIR="$HOME/.config/waybar"
WAYBAR_CONFIG="$WAYBAR_CONFIG_DIR/config-$MONITOR"
while true; do
sleep "$POLL_INTERVAL"
JSON="$(hyprctl -j monitors 2>/dev/null)"
echo "$JSON" | jq empty >/dev/null 2>&1 || continue
FOCUSED=$(echo "$JSON" | jq -r ".[] | select(.name==\"$MONITOR\") | .focused")
if [ "$FOCUSED" = "true" ]; then
# Blacklayer kapat
pkill -f "$BLACKLAYER_BIN $MONITOR" >/dev/null 2>&1
echo "false" > "$STATE_FILE"
# Waybar tekrar aç
if [ -f "$WAYBAR_CONFIG" ]; then
"$WAYBAR_BIN" -c "$WAYBAR_CONFIG" >/dev/null 2>&1 &
fi
exit 0
fi
done
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
set -e
WAYBAR_DIR="$HOME/.config/waybar"
BASE_CONFIG="$WAYBAR_DIR/config"
command -v hyprctl >/dev/null || { echo "[error] hyprctl not found"; exit 1; }
command -v jq >/dev/null || { echo "[error] jq not found"; exit 1; }
cd "$WAYBAR_DIR"
# -----------------------------
# 1) MONITORLER
# -----------------------------
MONITORS=$(hyprctl -j monitors | jq -r '.[].name')
[ -z "$MONITORS" ] && {
echo "[info] no monitors found, skipping"
exit 0
}
# -----------------------------
# 2) BASE CONFIG BELLEĞE AL
# (output temizlenmiş halde)
# -----------------------------
BASE_CONTENT=""
strip_output() {
sed \
-e 's/"output"[[:space:]]*:[[:space:]]*\[[^]]*\],[[:space:]]*//' \
-e '1s/^{//' \
"$1"
}
if [ -f "$BASE_CONFIG" ]; then
echo "[info] base config: config"
BASE_CONTENT="$(strip_output "$BASE_CONFIG")"
else
FIRST_MONITOR_CONFIG=$(ls config-* 2>/dev/null | head -n 1 || true)
[ -z "$FIRST_MONITOR_CONFIG" ] && {
echo "[error] no base config found"
exit 1
}
echo "[info] base config: $FIRST_MONITOR_CONFIG"
BASE_CONTENT="$(strip_output "$FIRST_MONITOR_CONFIG")"
fi
# -----------------------------
# 3) TEMİZLİK (MONITOR VARSA)
# -----------------------------
rm -f config
rm -f config-*
# -----------------------------
# 4) YENİ CONFIGLER
# -----------------------------
for MONITOR in $MONITORS; do
TARGET="config-$MONITOR"
{
echo '{'
echo " \"output\": [\"$MONITOR\"],"
echo "$BASE_CONTENT"
} > "$TARGET"
echo "[ok] generated $TARGET"
done
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
CONF="$HOME/.config/blacklayer/blacklayer.conf"
[ -f "$CONF" ] && source "$CONF"
# hypridle çağırdı ama lock kapalıysa → çık
[ "$run_lock" != "true" ] && exit 0
# zaten kilitliyse tekrar kilitleme
pgrep -x hyprlock >/dev/null && exit 0
hyprlock
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
hyprctl dispatch dpms on
hyprctl reload
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
CONF="$HOME/.config/blacklayer/blacklayer.conf"
[ -f "$CONF" ] && source "$CONF"
# sleep kapalıysa → çık
[ "$run_sleep" != "true" ] && exit 0
hyprctl dispatch dpms off