init commit
This commit is contained in:
Executable
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
TARGET="$HOME/.saved_cfg"
|
||||
FOLDERS_FILE="$TARGET/folders"
|
||||
|
||||
if [[ ! -f "$FOLDERS_FILE" ]]; then
|
||||
echo "Error: $FOLDERS_FILE not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$TARGET"
|
||||
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
# Trim whitespace
|
||||
folder="$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
|
||||
|
||||
# Skip empty lines and comments
|
||||
[[ -z "$folder" || "$folder" =~ ^# ]] && continue
|
||||
|
||||
SRC_PATH="$HOME/$folder"
|
||||
DEST_PATH="$TARGET/$folder"
|
||||
|
||||
if [[ -d "$SRC_PATH" ]]; then
|
||||
echo "Syncing $SRC_PATH -> $DEST_PATH"
|
||||
mkdir -p "$(dirname "$DEST_PATH")"
|
||||
|
||||
rsync -a --delete \
|
||||
--exclude='.git/' \
|
||||
"$SRC_PATH/" "$DEST_PATH/"
|
||||
else
|
||||
echo "Skipping $SRC_PATH (not found)"
|
||||
fi
|
||||
done < "$FOLDERS_FILE"
|
||||
|
||||
echo "Sync complete."
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# usage: ./change-wallpaper.sh /path/to/wallpaper.jpg
|
||||
|
||||
WP="$1"
|
||||
|
||||
if [ -z "$WP" ]; then
|
||||
echo "Usage: $0 /path/to/file.png|jpg"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PTH="$(realpath "$WP")"
|
||||
|
||||
# Set wallpaper on all monitors
|
||||
hyprctl hyprpaper wallpaper ",$PTH,cover"
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Check if exactly one argument is provided
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat "$1" | wl-copy
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
pasta_dir="$HOME/CopyPastas"
|
||||
|
||||
file=$(ls "$pasta_dir" | wofi --dmenu -p "Copypastas" -i)
|
||||
|
||||
wl-copy < "$pasta_dir/$file"
|
||||
Executable
+116
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
|
||||
# Path to your Hyprland config
|
||||
config_path = "/home/megnas/.config/hypr/hyprland.conf" # replace USERNAME
|
||||
|
||||
variables = {}
|
||||
bind_lines = []
|
||||
|
||||
# 1️⃣ Read config
|
||||
with open(config_path) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
# Parse variables
|
||||
if line.startswith("$"):
|
||||
m = re.match(r"(\$\w+)\s*=\s*(.*)", line)
|
||||
if m:
|
||||
var, val = m.groups()
|
||||
val = val.split("#")[0].strip() # remove comment
|
||||
variables[var] = val
|
||||
# Parse binds
|
||||
if line.startswith(("bind =","bindm =")): #"bindl =","bindel ="
|
||||
bind_lines.append(line.split("=",1)[1].strip())
|
||||
|
||||
# 2️⃣ Map commands to readable actions
|
||||
def command_to_text(parts):
|
||||
cmd = " ".join(parts[2:]).strip()
|
||||
# movefocus mapping
|
||||
movefocus_map = {"l":"left","r":"right","u":"up","d":"down"}
|
||||
if cmd.startswith("movefocus"):
|
||||
dir_key = cmd.split()[-1]
|
||||
dir_text = movefocus_map.get(dir_key, dir_key)
|
||||
return f"Move focus {dir_text}"
|
||||
if "split-workspace" in cmd:
|
||||
return f"Changes workspace to {parts[-1]}"
|
||||
if "exit" in cmd:
|
||||
return "Exits Hyprland"
|
||||
if "killactive" in cmd:
|
||||
return "Closes active window"
|
||||
if "exec" in cmd:
|
||||
# handle known variables
|
||||
cmd = cmd.replace("$fileManager", "Filemanager").replace("$menu", "Menu").replace("$terminal","Terminal")
|
||||
# remove leading "exec "
|
||||
if cmd.startswith("exec "):
|
||||
cmd_body = cmd[5:]
|
||||
else:
|
||||
cmd_body = cmd
|
||||
# Special case for screenshot script
|
||||
if "~/.scripts/screenshot.sh" in cmd_body:
|
||||
return "Takes screenshot"
|
||||
if "~/.scripts/hypr-help.sh" in cmd_body:
|
||||
return "Shows this help menu"
|
||||
return f"Runs {cmd_body}"
|
||||
if "togglefloating" in cmd:
|
||||
return "Toggles floating for window"
|
||||
if "fullscreen" in cmd:
|
||||
return "Toggles fullscreen"
|
||||
if "pseudo" in cmd:
|
||||
return "Pseudotiles window (dwindle)"
|
||||
if "togglesplit" in cmd:
|
||||
return "Toggles split (dwindle)"
|
||||
if "focusmonitor" in cmd:
|
||||
return "Changes focused monitor"
|
||||
if "split-changemonitor" in cmd:
|
||||
return "Moves window to next monitor"
|
||||
if "togglespecialworkspace" in cmd:
|
||||
return f"Toggles special workspace {parts[-1]}"
|
||||
if "movetoworkspace" in cmd:
|
||||
return f"Moves window to {parts[-1]}"
|
||||
if "split-cycleworkspacesnowrap" in cmd:
|
||||
return f"Cycles workspace {parts[-1]}"
|
||||
if "movewindow" in cmd:
|
||||
return "Move window with mouse"
|
||||
if "resizewindow" in cmd:
|
||||
return "Resize window with mouse"
|
||||
# fallback
|
||||
return cmd
|
||||
|
||||
# 3️⃣ Resolve variables in combos and rename mouse keys
|
||||
def resolve_combo(combo):
|
||||
combo = combo.replace("$mainMod", variables.get("$mainMod",""))
|
||||
combo = combo.replace("#"," + ") # ALT#SUPER -> ALT + SUPER
|
||||
# Mouse key mapping
|
||||
mouse_map = {
|
||||
"mouse:272": "Mouse (left click)",
|
||||
"mouse:273": "Mouse (right click)",
|
||||
"mouse_down": "Mouse (scroll down)",
|
||||
"mouse_up": "Mouse (scroll up)",
|
||||
"Print": "PrintScreen"
|
||||
}
|
||||
combo = mouse_map.get(combo, combo)
|
||||
return combo.strip(" +")
|
||||
|
||||
# 4️⃣ Format each bind
|
||||
formatted = []
|
||||
for b in bind_lines:
|
||||
parts = [p.strip() for p in b.split(",")]
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
combo = resolve_combo(parts[0])
|
||||
key = resolve_combo(parts[1])
|
||||
# combine combo + key
|
||||
if combo and key:
|
||||
combo_text = f"{combo} + {key}"
|
||||
elif combo:
|
||||
combo_text = combo
|
||||
else:
|
||||
combo_text = key
|
||||
action = command_to_text(parts)
|
||||
formatted.append(f"{combo_text} -> {action}")
|
||||
|
||||
# 5️⃣ Print results
|
||||
for line in formatted:
|
||||
print(line)
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
/home/megnas/.scripts/hyprland-parse.py /home/megnas/.config/hypr/hyprland.conf | wofi --dmenu -p "Hyprland Keybinds" -i
|
||||
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
||||
KEY_TRANSLATIONS = {
|
||||
"Print": "PrintScreen",
|
||||
"mouse_up": "Mouse Up",
|
||||
"mouse_down": "Mouse Down",
|
||||
"mouse:272": "Left Click",
|
||||
"mouse:273": "Right Click",
|
||||
"left": "Left Arrow",
|
||||
"right": "Right Arrow",
|
||||
"up": "Up Arrow",
|
||||
"down": "Down Arrow",
|
||||
}
|
||||
|
||||
|
||||
def normalize_key_name(key: str) -> str:
|
||||
key = key.strip()
|
||||
return KEY_TRANSLATIONS.get(key, key)
|
||||
|
||||
|
||||
def extract_main_mod(lines):
|
||||
"""
|
||||
Extracts $mainMod value, e.g.
|
||||
$mainMod = SUPER
|
||||
"""
|
||||
pattern = re.compile(r"^\s*\$mainMod\s*=\s*([A-Za-z0-9_]+)")
|
||||
for line in lines:
|
||||
match = pattern.match(line)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def normalize_key(mods: str, key: str, main_mod_value: str) -> str:
|
||||
mods = mods.strip()
|
||||
key = normalize_key_name(key.strip())
|
||||
|
||||
if mods:
|
||||
mod_parts = mods.split()
|
||||
|
||||
resolved_mods = []
|
||||
for m in mod_parts:
|
||||
if m == "$mainMod" and main_mod_value:
|
||||
resolved_mods.append(main_mod_value)
|
||||
else:
|
||||
resolved_mods.append(m)
|
||||
|
||||
return " + ".join(resolved_mods) + f" + {key}"
|
||||
|
||||
return key
|
||||
|
||||
|
||||
def parse_hyprland_config(path: str):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
main_mod_value = extract_main_mod(lines)
|
||||
|
||||
results = []
|
||||
last_comment = None
|
||||
|
||||
bind_pattern = re.compile(r"^\s*(bindm?|bind)\s*=\s*(.+)$")
|
||||
|
||||
for line in lines:
|
||||
stripped = line.strip()
|
||||
|
||||
if stripped.startswith("#"):
|
||||
last_comment = stripped.lstrip("#").strip()
|
||||
continue
|
||||
|
||||
match = bind_pattern.match(line)
|
||||
if match:
|
||||
full_cmd = match.group(2)
|
||||
parts = [p.strip() for p in full_cmd.split(",")]
|
||||
|
||||
if len(parts) >= 2:
|
||||
mods = parts[0]
|
||||
key = parts[1]
|
||||
|
||||
keybind = normalize_key(mods, key, main_mod_value)
|
||||
comment = last_comment if last_comment else "(no comment)"
|
||||
|
||||
results.append(f"{keybind} = {comment}")
|
||||
|
||||
last_comment = None
|
||||
else:
|
||||
if stripped != "":
|
||||
last_comment = None
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} <hyprland.conf>")
|
||||
sys.exit(1)
|
||||
|
||||
config_path = sys.argv[1]
|
||||
keybinds = parse_hyprland_config(config_path)
|
||||
|
||||
for line in keybinds:
|
||||
print(line)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if at least 2 arguments are passed
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: open [file]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILE="$1"
|
||||
|
||||
file_types=$(file -b "$FILE")
|
||||
|
||||
if echo "$file_types" | grep -q "text"; then
|
||||
|
||||
# Open .md file with glow
|
||||
if [[ "$FILE" == *.md ]]; then
|
||||
glow -t "$FILE"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#Open other files with bat
|
||||
bat "$FILE"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo "Opening this file type is not supported!"
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Check if exactly one argument is provided
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Append the output of wl-paste to the provided file
|
||||
wl-paste --type text/plain > "$1"
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
if pkill wofi; then
|
||||
# If successful, exit the script/app
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Define options as a single string, separated by newlines
|
||||
OPTIONS="Shutdown\nReboot\nSuspend\nHibernate\nLogout"
|
||||
|
||||
# Use wofi to present the options and get the user's choice
|
||||
SELECTED=$(echo -e "$OPTIONS" | wofi -W 24% -H 26% -dmenu -s ~/.config/wofi/shutdown.css --prompt "Power Menu")
|
||||
|
||||
# Act on the user's choice
|
||||
case "$SELECTED" in
|
||||
"Shutdown")
|
||||
shutdown now
|
||||
;;
|
||||
"Reboot")
|
||||
reboot
|
||||
;;
|
||||
"Suspend")
|
||||
systemctl suspend
|
||||
;;
|
||||
"Hibernate")
|
||||
systemctl hibernate
|
||||
;;
|
||||
"Logout")
|
||||
# This command is for Hyprland.
|
||||
# If you use a different compositor, change this line.
|
||||
hyprctl dispatch exit
|
||||
;;
|
||||
esac
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Kill existing Waybar instances
|
||||
if pgrep -x waybar > /dev/null; then
|
||||
pkill -x waybar
|
||||
# Wait until all processes are fully stopped
|
||||
while pgrep -x waybar > /dev/null; do
|
||||
sleep 0.1
|
||||
done
|
||||
fi
|
||||
|
||||
# Start Waybar in background
|
||||
waybar >/dev/null 2>&1 &
|
||||
disown
|
||||
|
||||
echo "Waybar reloaded."
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
dir="$HOME/Pictures/Screenshots"
|
||||
file="$(date '+%F_%H-%M-%S').png"
|
||||
|
||||
grim -g "$(slurp)" "$dir"/"$file"
|
||||
|
||||
copyq write image/png - < "$dir/$file"
|
||||
copyq select 0
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DIR="$HOME/Wallpapers"
|
||||
|
||||
|
||||
# Build list: filename<TAB>fullpath
|
||||
file_list=$(find "$DIR" -type f 2>/dev/null | sort | while read -r f; do
|
||||
printf "%s\t%s\n" "$(basename "$f")" "$f"
|
||||
done)
|
||||
|
||||
# Show only filename column in wofi
|
||||
selected_name=$(printf "%s\n" "$file_list" | cut -f1 | \
|
||||
wofi --dmenu --prompt "Select file:")
|
||||
|
||||
# Get full path matching selected filename (first match)
|
||||
if [[ -n "$selected_name" ]]; then
|
||||
selected_file=$(printf "%s\n" "$file_list" | \
|
||||
awk -F'\t' -v name="$selected_name" '$1 == name { print $2; exit }')
|
||||
|
||||
notify-send "Selected File" "$selected_file"
|
||||
hyprctl hyprpaper wallpaper ",$selected_file,cover"
|
||||
fi
|
||||
Reference in New Issue
Block a user