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

74
tofi/config Normal file
View file

@ -0,0 +1,74 @@
# Fonts
font = "JetBrains Mono Nerd Font"
font-size = 12
hint-font = true
# Text theming
text-color = #CCCCCC
prompt-color = #CCCCCC
prompt-background = #00000000
prompt-background-padding = 0
prompt-background-corner-radius = 0
placeholder-color = #666666
placeholder-background = #00000000
input-color = #CCCCCC
input-background = #00000000
default-result-color = #CCCCCC
default-result-background = #00000000
selection-color = #CCCCCC
selection-background = #D55D7C
selection-background-padding = 4
selection-background-corner-radius = 0
selection-match-color = #222222
# Text cursor theme
text-cursor-style = block
text-cursor-color = #CCCCCC
text-cursor-corner-radius = 0
text-cursor-thickness = 2
# Text layout
prompt-text = ""
placeholder-text = "Type to search..."
num-results = 0
result-spacing = 2
horizontal = false
min-input-width = 0
# Window theming
width = 480
height = 320
background-color = #000000B3
border-color = #D55D7CEE
outline-width = 0
border-width = 3
corner-radius = 10
padding-top = 10
padding-bottom = 10
padding-left = 15
padding-right = 15
clip-to-padding = true
scale = true
# Window positioning
output = ""
anchor = center
exclusive-zone = -1
margin-top = 0
margin-bottom = 0
margin-left = 0
margin-right = 0
# Behaviour
hide-cursor = false
text-cursor = true
history = true
fuzzy-match = true
require-match = true
auto-accept-single = false
hide-input = false
hidden-character = "*"
drun-launch = false
late-keyboard-init = false
multi-instance = false
ascii-input = false

64
tofi/select_audio.py Executable file
View file

@ -0,0 +1,64 @@
#!/usr/bin/env python3
import subprocess
import re
def parse_wpctl_status():
devices = []
current_section = None
output = subprocess.run(["wpctl", "status"], capture_output=True, text=True).stdout.splitlines()
for line in output:
line = line.rstrip()
if "Sinks:" in line:
current_section = "sink"
continue
elif "Sources:" in line:
current_section = "source"
continue
elif re.match(r"^[^\s]", line):
current_section = None
if current_section:
m = re.search(r"\*\s*|\s*(\d+)\.\s+(.*?)\s+\[vol:", line)
if m:
id_match = re.search(r"(\d+)\.", line)
dev_id = id_match.group(1) if id_match else None
name_match = re.search(r"\d+\.\s+(.*?)\s+\[vol:", line)
name = name_match.group(1) if name_match else None
if dev_id and name:
devices.append((current_section, dev_id, name))
return devices
def main():
devices = parse_wpctl_status()
if not devices:
print("No devices found.")
return
# Prepare choices and a mapping from display line to device ID
choices = []
id_map = {}
for dev_type, dev_id, name in devices:
label = "O" if dev_type == "sink" else "I"
line = f"{label} {name}"
choices.append(line)
id_map[line] = dev_id
result = subprocess.run(["tofi"], input="\n".join(choices), capture_output=True, text=True)
choice = result.stdout.strip()
if not choice:
return
selected_id = id_map.get(choice)
if selected_id:
subprocess.run(["wpctl", "set-default", selected_id])
subprocess.run(["notify-send", f"Set default device to {choice}"])
if __name__ == "__main__":
main()