-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewScript.py
More file actions
executable file
·45 lines (38 loc) · 1.28 KB
/
Copy pathnewScript.py
File metadata and controls
executable file
·45 lines (38 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/env python3
import subprocess as sp
from typing import List, Optional
import sys
PROMPT: str = "Name your python script:"
SPACE: List[str] = ["echo", " "]
DFY: List[str] = ["dunstify", "-u", "low"]
def DMENU(prompt: str) -> Optional[str]:
dmenu: List[str] = ["dmenu", "-m", "0", "-fn", "VictorMono:size=17:italic", "-sf", "#5F5F00", "-nf",
"green", "-nb", "black", "-sb", "black", "-p", f"{prompt}"]
dm_command = sp.Popen(dmenu, stdin=sp.PIPE, stdout=sp.PIPE, text=True)
output, err = dm_command.communicate()
if dm_command.returncode != 0:
print(err)
sys.exit(1)
else:
if output:
return output.strip()
else:
print("Could not return dmenu value")
return None
def user_input(path: str) -> Optional[List[str]]:
SPELL: List[str] = ['wezterm', '-e', 'nvim', f'{path}']
write_file = sp.run(SPELL, capture_output=True, text=True)
err = write_file.stderr
if err:
print(err)
return None
else:
write_file.stdout.splitlines()
def spell() -> Optional[str]:
prompt_result = DMENU(PROMPT)
if prompt_result is not None:
user_input(prompt_result)
else:
print("Dmenu command failed to run properly")
sys.exit(1)
spell()