first commit

This commit is contained in:
Jeena 2025-08-28 11:23:01 +09:00
commit 8e85fe845b
22 changed files with 1449 additions and 0 deletions

120
hypr/scripts/dynamic-borders.sh Executable file
View file

@ -0,0 +1,120 @@
#!/usr/bin/env bash
function handle {
if [[ ${1:0:10} == "openwindow" ]]
then
window_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=1)
workspace_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=2)
if [[ $workspace_id == "special" ]]
then
workspace_id=-99
fi
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $windows -eq 1 ]]
then
floating_status=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$window_id\" ) | .floating" )
if [[ $floating_status == "false" ]]
then
hyprctl dispatch setprop address:0x$window_id noborder 1
else
hyprctl dispatch setprop address:0x$window_id noborder 0
return
fi
elif [[ $windows -eq 2 ]]
then
addresses=$(hyprctl clients -j | jq -r --arg foo "$foo" ".[] | select(.workspace.id == $workspace_id) | .address")
for address in $addresses
do
if [[ "$address" != "$window_id" ]]; then
hyprctl dispatch setprop address:$(echo $address | xargs) noborder 0
fi
done
fi
elif [[ ${1:0:10} == "movewindow" ]]
then
window_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=1)
workspace_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=2)
# Sepcial workspaces have an id of -99, they need to be handled separately
if [[ $workspace_id == "special" ]]
then
workspace_id=-99
fi
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $windows -eq 1 ]]
then
# Check if the current window is floating and then set the border accordingly
floating_status=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$window_id\" ) | .floating" )
if [[ $floating_status == "false" ]]
then
hyprctl dispatch setprop address:0x$window_id noborder 1
else
hyprctl dispatch setprop address:0x$window_id noborder 0
return
fi
elif [[ $windows -eq 2 ]]
then
addresses=$(hyprctl clients -j | jq -r --arg foo "$foo" ".[] | select(.workspace.id == $workspace_id) | .address")
for address in $addresses
do
if [[ "$address" != "$window_id" ]]; then
hyprctl dispatch setprop address:$(echo $address | xargs) noborder 0
fi
done
fi
# Handle all the other workspaces with only one window
single_window_workspaces=$(hyprctl workspaces -j | jq '.[] | select(.windows == 1)' | jq ".id")
for workspace in $single_window_workspaces
do
window=$(hyprctl clients -j | jq ".[] | select(.workspace.id == $workspace) | .address")
hyprctl dispatch setprop address:$(echo $window | xargs) noborder 1
done
elif [[ ${1:0:11} == "closewindow" ]]
then
workspace_id=$(hyprctl activewindow -j | jq ".workspace.id")
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $windows -eq 1 ]]
then
window_id=$(hyprctl activewindow -j | jq -r ".address")
floating_status=$(hyprctl activewindow -j | jq ".floating")
if [[ $floating_status == "false" ]]
then
hyprctl dispatch setprop address:$window_id noborder 1
else
hyprctl dispatch setprop address:$window_id noborder 0
return
fi
fi
elif [[ ${1:0:18} == "changefloatingmode" ]]
then
floating_status=$(echo $1 | cut --delimiter ">" --fields 3 | cut --delimiter "," --fields 2)
address="0x$(echo $1 | cut --delimiter ">" --fields 3 | cut --delimiter "," --fields 1)"
workspace_id=$(hyprctl clients -j | jq --arg address "$address" '.[] | select(.address == $address) | .workspace.id')
if [[ $floating_status -eq 1 ]]
then
hyprctl dispatch setprop address:$address noborder 0
else
no_windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $no_windows -eq 1 ]]
then
hyprctl dispatch setprop address:$address noborder 1
else
hyprctl dispatch setprop address:$address noborder 0
fi
fi
fi
}
# Socket directory has changed in Hyprland v0.40.0
# socat - UNIX-CONNECT:/tmp/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done
socat -U - UNIX-CONNECT:$(echo $XDG_RUNTIME_DIR)/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done

126
hypr/scripts/emoji-picker.py Executable file
View file

@ -0,0 +1,126 @@
#!/usr/bin/env python3
import json
import os
import subprocess
import sys
import logging
from pathlib import Path
# Setup logging
logging.basicConfig(
level=logging.INFO, # default level
format="%(levelname)s: %(message)s"
)
logger = logging.getLogger(__name__)
# Optional: pyperclip fallback
try:
import pyperclip
HAVE_PYPERCLIP = True
except ImportError:
HAVE_PYPERCLIP = False
EMOJI_URL = "https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json"
class EmojiCache:
"""Handles downloading and caching the emoji list in XDG_CACHE_HOME."""
def __init__(self):
xdg_cache = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache"))
self.cache_dir = xdg_cache / "emoji-picker"
self.cache_file = self.cache_dir / "emoji-list.txt"
self.cache_dir.mkdir(parents=True, exist_ok=True)
logger.debug(f"Cache directory: {self.cache_dir}")
def fetch(self):
"""Download or return cached emoji list."""
if not self.cache_file.exists():
self.download()
else:
logger.debug(f"Using cached emoji list at {self.cache_file}")
return self.cache_file
def download(self):
try:
import requests
except ImportError:
logger.error("requests module is required to fetch emoji list")
sys.exit(1)
logger.info("Downloading emoji list...")
data = requests.get(EMOJI_URL).json()
lines = []
for e in data:
emoji = e.get("emoji", "")
description = e.get("description", "")
category = e.get("category", "")
aliases = e.get("aliases", [])
tags = e.get("tags", [])
line = emoji + " - " + description + " - " + category
line = self.add_unique(aliases, line)
line = self.add_unique(tags, line)
lines.append(line)
self.cache_file.write_text("\n".join(lines), encoding="utf-8")
logger.info(f"Emoji list cached at {self.cache_file}")
@staticmethod
def add_unique(words, line):
for word in words:
if word.lower() not in line.lower():
line += " " + word
return line
class EmojiPicker:
"""Shows menu with tofi and copies selected emoji to clipboard."""
def __init__(self, emoji_file):
self.emoji_file = Path(emoji_file)
def pick(self):
try:
with self.emoji_file.open("r", encoding="utf-8") as f:
choices = f.read().splitlines()
result = subprocess.run(
[
"tofi",
"--fuzzy-match", "true",
"--require-match", "true",
"--history", "true",
"--history-file", str(Path.home() / ".cache/emoji-picker/history.txt")
],
input="\n".join(choices),
capture_output=True,
text=True
)
chosen_line = result.stdout.strip()
if not chosen_line:
logger.debug("No selection made")
return
emoji = chosen_line.split()[0] # just the emoji
self.copy_to_clipboard(emoji)
logger.info(f"Copied {emoji} to clipboard")
except FileNotFoundError:
logger.error("tofi not found!")
@staticmethod
def copy_to_clipboard(text):
if HAVE_PYPERCLIP:
pyperclip.copy(text)
else:
try:
subprocess.run(["wl-copy"], input=text.encode(), check=True)
except FileNotFoundError:
logger.error("wl-copy not found and pyperclip not available")
def main():
cache = EmojiCache()
emoji_file = cache.fetch()
picker = EmojiPicker(emoji_file)
picker.pick()
if __name__ == "__main__":
main()

13
hypr/scripts/launch-menu.sh Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
SCRIPTS="$HOME/.config/hypr/menu.list"
SCRIPT_PATH="$HOME/.config/hypr/scripts"
# Kill existing tofi instance if running
pkill -x tofi || {
chosen=$(cut -d'=' -f1 "$SCRIPTS" | tofi)
if [ -n "$chosen" ]; then
script=$(awk -F= -v sel="$chosen" '$1==sel {print $2}' "$SCRIPTS")
[ -n "$SCRIPT_PATH/$script" ] && eval "$SCRIPT_PATH/$script" &
fi
}

3
hypr/scripts/launch-tofi.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
pkill tofi-drun || tofi-drun --drun-launch=true

3
hypr/scripts/lock.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
hyprctl switchxkblayout all 0
loginctl lock-session