feat: Add a ton of hyprland config
This commit is contained in:
1
.config/hypr/scripts/.gitignore
vendored
Normal file
1
.config/hypr/scripts/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.venv
|
||||
135
.config/hypr/scripts/desk.py
Executable file
135
.config/hypr/scripts/desk.py
Executable file
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/python3
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
# Check if first arg is colour
|
||||
waybar = {}
|
||||
waybar["SELECTED"] = '<span underline="low">'
|
||||
waybar["DEFAULT"] = '<span foreground="#ffffff">'
|
||||
waybar["WHITE"]='<span foreground="#ffffff">'
|
||||
waybar["RED"]='<span foreground="#ff0000">'
|
||||
waybar["GREEN"]='<span foreground="#60d090">'
|
||||
waybar["YELLOW"]='<span foreground="#ffff00">'
|
||||
waybar["BLUE"]='<span foreground="#0000ff">'
|
||||
waybar["NC"]='</span>'
|
||||
|
||||
shell = {}
|
||||
shell["SELECTED"]='\033[0;32m'
|
||||
shell["WHITE"]='\033[0;37m'
|
||||
shell["RED"]='\033[0;31m'
|
||||
shell["GREEN"]='\033[0;32m'
|
||||
shell["YELLOW"]='\033[0;33m'
|
||||
shell["BLUE"]='\033[0;34m'
|
||||
shell["NC"]='\033[0m'
|
||||
|
||||
|
||||
|
||||
def get_info():
|
||||
state = subprocess.run(["hyprctl", "printstate"], capture_output=True, text=True)
|
||||
state = state.stdout.splitlines()
|
||||
state.pop(0) # Remove the first line
|
||||
info = {}
|
||||
while True:
|
||||
if len(state) == 0:
|
||||
break
|
||||
|
||||
line = state.pop(0)
|
||||
if line == "":
|
||||
continue
|
||||
if "-" not in line:
|
||||
break
|
||||
key, value = line.split(": ")
|
||||
key = key.strip().removeprefix("-").strip()
|
||||
value = value.strip()
|
||||
desk_id = value
|
||||
info[desk_id] = {"name": key}
|
||||
for i in range(4):
|
||||
line = state.pop(0)
|
||||
if line == "":
|
||||
break
|
||||
line = line.split(": ")
|
||||
if len(line) == 2:
|
||||
key, value = line
|
||||
key = key.strip()
|
||||
value = value.strip()
|
||||
info[desk_id][key] = value
|
||||
return info
|
||||
|
||||
def get_icon(desk_name, focused=False):
|
||||
# Get the icon for the desk
|
||||
icon = ""
|
||||
desk_name = desk_name.strip().lower()
|
||||
if desk_name == "coding":
|
||||
return ""
|
||||
if desk_name == "web" or desk_name == "internet":
|
||||
return ""
|
||||
if desk_name == "social":
|
||||
return ""
|
||||
|
||||
|
||||
return "" if focused else ""
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Check for arguments
|
||||
parser = argparse.ArgumentParser(description="hyprland desk script")
|
||||
parser.add_argument("-d", "--desk", type=int, help="Desk number to switch to")
|
||||
parser.add_argument("-w", "--waybar", action="store_true", help="Waybar mode")
|
||||
parser.add_argument("-i", "--info", action="store_true", help="Info mode")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose mode")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.waybar or args.info:
|
||||
colours = waybar if args.waybar else shell
|
||||
# Get info from hyprctl printstate
|
||||
info = get_info()
|
||||
output = ""
|
||||
if args.desk:
|
||||
desk_num = args.desk
|
||||
if str(desk_num) not in info:
|
||||
print(f"Desk {desk_num} does not exist")
|
||||
sys.exit(1)
|
||||
desk = info[str(desk_num)]
|
||||
if args.verbose:
|
||||
print(desk)
|
||||
if desk["Populated"] == "false" and desk["Focused"] == "false":
|
||||
print(f"Desk {desk_num} is empty")
|
||||
sys.exit(1)
|
||||
|
||||
if desk["Focused"] == "true":
|
||||
output += f"{colours['SELECTED']} {desk_num}: {get_icon(desk['name'],True)} {colours['NC']} "
|
||||
else:
|
||||
output += f"{colours["DEFAULT"]} {desk_num}: {get_icon(desk['name'])} {colours['NC']} "
|
||||
print(output)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
for i in range(1, int(max(info.keys()))+1):
|
||||
if str(i) not in info:
|
||||
continue
|
||||
desk = info[str(i)]
|
||||
if desk["Populated"] == "false" and desk["Focused"] == "false":
|
||||
continue
|
||||
if args.verbose:
|
||||
print(desk)
|
||||
|
||||
if desk["Focused"] == "true":
|
||||
output += f"{colours['SELECTED']} {get_icon(desk['name'],True)} {colours['NC']} "
|
||||
else:
|
||||
output += f"{colours["DEFAULT"]} {get_icon(desk['name'])} {colours['NC']} "
|
||||
|
||||
|
||||
print(output)
|
||||
sys.exit(0)
|
||||
if args.desk:
|
||||
# Switch to desk
|
||||
if args.verbose:
|
||||
print(f"Switching to desk {args.desk}")
|
||||
|
||||
subprocess.run(["hyprctl", "dispatch", "vdesk", str(args.desk)])
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
||||
9
.config/hypr/scripts/get-volume.sh
Executable file
9
.config/hypr/scripts/get-volume.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
# Check if muted
|
||||
if wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q "[MUTED]"; then
|
||||
# If muted, show notification
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}' | sed 's/\.0*$//g')% "
|
||||
0
.config/hypr/scripts/search-windows.log
Normal file
0
.config/hypr/scripts/search-windows.log
Normal file
44
.config/hypr/scripts/search-windows.sh
Executable file
44
.config/hypr/scripts/search-windows.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check if tofi is running
|
||||
if pgrep -x "tofi" > /dev/null; then
|
||||
# Passing as regular tab
|
||||
ydotool key 15:1 15:0
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
# Get a list of open windows
|
||||
WINDOWS=$(hyprctl clients | grep "title: " | sed 's/.*title: //')
|
||||
|
||||
# If there are no open windows, exit
|
||||
[ -z "$WINDOWS" ] && exit
|
||||
|
||||
# Use tofi to select a window
|
||||
SELECTED=$(echo "$WINDOWS" | tofi --num-results 10 --padding-left 20% --padding-top 20% --prompt-text "Select a window: ")
|
||||
|
||||
# If a window was selected, focus it
|
||||
if [ -n "$SELECTED" ]; then
|
||||
echo "Focusing window: $SELECTED"
|
||||
# Check if the selected window is on special workspace
|
||||
# hyprctl clients | grep "$SELECTED" -A 10 | grep workspace
|
||||
# returns like workspace: -98 (special:magic)
|
||||
workspace=$(hyprctl clients | grep "$SELECTED" -A 10 | grep workspace)
|
||||
# if workspace is special, try to focus it
|
||||
if [[ $workspace == *"special:"* ]]; then
|
||||
# Get the workspace name (after the colon)
|
||||
workspace_name=$(echo "$workspace" | sed -E 's/.*:\s*([^)]*).*/\1/')
|
||||
# Remove number and prefix
|
||||
|
||||
echo "Focusing special workspace: $workspace_name"
|
||||
# Focus the workspace
|
||||
hyprctl dispatch togglespecialworkspace "$workspace_name"
|
||||
fi
|
||||
# Get the window ID
|
||||
window_id=$(hyprctl clients | grep "$SELECTED" -A 10 | grep pid)
|
||||
# Get the window ID (after the colon)
|
||||
window_id=$(echo "$window_id" | sed -E 's/.*:\s*([^)]*).*/\1/')
|
||||
echo "Window ID: $window_id"
|
||||
|
||||
hyprctl dispatch focuswindow pid:"$window_id"
|
||||
fi
|
||||
10
.config/hypr/scripts/volume.sh
Executable file
10
.config/hypr/scripts/volume.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
hyprctl dismissnotify
|
||||
# Check if muted
|
||||
if wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q "[MUTED]"; then
|
||||
# If muted, show notification
|
||||
hyprctl notify -1 5000 0 "Volume muted"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
hyprctl notify -1 5000 0 "Volume $(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}' | sed 's/\.0*$//g')%"
|
||||
Reference in New Issue
Block a user