Refactor and some moves
parent
5956d82ee0
commit
25dfc185c2
11
README.md
11
README.md
|
@ -1,7 +1,16 @@
|
|||
Patches
|
||||
DWM
|
||||
--
|
||||
Dynamic Window Manager(dwm) 6.2 with patches for gaps
|
||||
|
||||
Bar
|
||||
--
|
||||
I use my own [bar](https://git.nakidai.ru/nakidai/dwmbar) written in python. Bar script itself you can find [there](https://git.nakidai.ru/nakidai/dwmscripts/src/branch/master/sysbar.py).
|
||||
To run it just write something like:
|
||||
```sh
|
||||
python sysbar.py &
|
||||
exec dwm
|
||||
```
|
||||
|
||||
Themes
|
||||
--
|
||||
- Catppuccin frappe
|
||||
|
|
26
config.h
26
config.h
|
@ -1,9 +1,9 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#define TERMINAL "st"
|
||||
#define EDITOR "nvim"
|
||||
#define BROWSER "firefox"
|
||||
#define SCRIPTS_PATH "/home/naki/dwmscripts/"
|
||||
#define TERMINAL "st"
|
||||
#define EDITOR "nvim"
|
||||
#define BROWSER "firefox"
|
||||
#define SCREENSHOTS_PATH "/home/naki/pic/screenshots/"
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||
|
@ -70,30 +70,20 @@ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont,
|
|||
|
||||
static const char *termcmd[] = { TERMINAL, NULL };
|
||||
static const char *editorcmd[] = { TERMINAL, EDITOR, NULL };
|
||||
static const char *browsercmd[] = { BROWSER, NULL };
|
||||
static const char *discordcmd[] = { "discord", NULL };
|
||||
|
||||
static const char *volupcmd[] = { "amixer", "-D", "pulse", "sset", "Master", "5%+", "unmute", NULL };
|
||||
static const char *voldowncmd[] = { "amixer", "-D", "pulse", "sset", "Master", "5%-", "unmute", NULL };
|
||||
|
||||
static const char *browsercmd[] = { BROWSER, NULL };
|
||||
static const char *discordcmd[] = { "discord", NULL };
|
||||
static const char *scrotshcmd[] = { SCRIPTS_PATH "/scrot.sh", NULL };
|
||||
static const char *scrotpycmd[] = { "python", SCRIPTS_PATH "/scrot.py", NULL };
|
||||
static const char *layoutcmd[] = { "python", SCRIPTS_PATH "/layout.py", NULL };
|
||||
static const char *convertcmd[] = { SCRIPTS_PATH "/convert.sh", NULL };
|
||||
static const char *calccmd[] = { SCRIPTS_PATH "/calc.sh", NULL };
|
||||
static const char *scrotcmd[] = { "scrot", "-s", "-f", SCREENSHOTS_PATH "/%F_%T_$wx$h.png", "-e", "xclip -selection clipboard -target image/png -i $f", NULL };
|
||||
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
|
||||
/* Utilities */
|
||||
{ MODKEY, XK_F5, spawn, SHCMD("setxkbmap us") }, /* | if kludge bottom doesn't work - */
|
||||
{ MODKEY, XK_F6, spawn, SHCMD("setxkbmap ru") }, /* / it can change your layout */
|
||||
{ MODKEY, XK_space, spawn, {.v = layoutcmd } }, /* kludge for switching layout */
|
||||
|
||||
{ 0, XK_Print, spawn, {.v = scrotshcmd } }, /* print screen */
|
||||
{ MODKEY, XK_v, spawn, {.v = convertcmd } },
|
||||
{ 0, XK_Print, spawn, {.v = scrotcmd } }, /* print screen */
|
||||
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY, XK_c, spawn, {.v = calccmd} },
|
||||
|
||||
{ MODKEY, 0x5b, spawn, {.v = voldowncmd } }, /* | Multimedia keys */
|
||||
{ MODKEY, 0x5d, spawn, {.v = volupcmd } }, /* / */
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
import os
|
||||
from typing import List
|
||||
import subprocess
|
||||
import requests
|
||||
|
||||
|
||||
def get_ex_rates() -> float:
|
||||
response = \
|
||||
requests.get("https://www.cbr-xml-daily.ru/daily_json.js").json()
|
||||
out = {}
|
||||
for valute in response["Valute"]:
|
||||
out[valute] = response["Valute"][valute]["Value"]
|
||||
return out
|
||||
|
||||
|
||||
def show_command_out(command: str, return_out: str = True) -> str | None:
|
||||
if not return_out:
|
||||
os.system(command)
|
||||
return
|
||||
return subprocess.check_output(
|
||||
command,
|
||||
shell=True
|
||||
).decode("utf-8")
|
||||
|
||||
|
||||
def show_dmenu_out(question: str, answers: List[str] = None) -> str:
|
||||
if not answers:
|
||||
return show_command_out(
|
||||
'cat /dev/null | dmenu -p "{}"'.format(
|
||||
question
|
||||
)
|
||||
)[:-1]
|
||||
return show_command_out(
|
||||
'echo "{}" | dmenu -p "{}"'.format(
|
||||
"".join([f"{x}\n" for x in answers])[:-1],
|
||||
question
|
||||
)
|
||||
)[:-1]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
sentence = show_dmenu_out(">")
|
||||
try:
|
||||
ex_rates = get_ex_rates()
|
||||
for ex_rate in ex_rates:
|
||||
locals()[ex_rate] = ex_rates[ex_rate]
|
||||
answer = str(eval(sentence))
|
||||
except Exception as exc:
|
||||
answer = str(exc)
|
||||
do_copy = show_dmenu_out(f"{sentence} = {answer}", ["Exit", "Copy"])
|
||||
if do_copy == "Copy":
|
||||
show_command_out(
|
||||
f'echo "{answer}" | xclip -selection clipboard -r',
|
||||
False
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1 +0,0 @@
|
|||
python /home/naki/dwmscripts/calc.py
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# xclip -o > /tmp/convert.txt; iconv -f WINDOWS-1251 -t UTF-8 /tmp/convert.txt | xclip -selection clipboard
|
||||
# { echo "." & ms-gen 10 9; } | xclip -selection clipboard
|
||||
# /home/plaza/dwmscripts/main 10 10 | xclip -selection clipboard
|
||||
# xclip -o | base64 | xclip -selection clibboard -r
|
||||
# printf "worried\nthinking\nshrug\nangry\nangrysight\ncuddles\nhappy\ncrying\ndancing\nconfused" | dmenu -l 20 -p "Select emoji" |
|
||||
python /home/naki/dwmscripts/emoji.py
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"panic": "(つ﹏⊂)",
|
||||
"thinking": "(;・・)ゞ",
|
||||
"shrug": "¯\\(ツ)/¯",
|
||||
"angry": "ヾ(`д´*)ノ",
|
||||
"angrysight": "(⚞︵⚟)",
|
||||
"happysight": "(≧ω≦)",
|
||||
"cuddles": "(つ´∀`)つ",
|
||||
"happy": "(^▽^)",
|
||||
"cryinghappy": "(*≧▽≦)",
|
||||
"confusedhappy": "(.❛ ᴗ ❛.)",
|
||||
"crying": "( ≧Д≦)",
|
||||
"dancing": "ヽ(o´∀´)ノ♪♬",
|
||||
"confused": "(´・_・´)",
|
||||
"cute": "(⌒ω⌒)",
|
||||
"sleeping": "(∪。∪)。。。zzz",
|
||||
"writing": "__φ(..)"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
from dwmbar.bar import Bar
|
||||
import dwmbar.modules
|
||||
from dwmbar.other import get_command_out
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,48 +0,0 @@
|
|||
from dwmbar.modules import BarItem
|
||||
import os
|
||||
from time import sleep, time
|
||||
|
||||
|
||||
class Bar:
|
||||
def __init__(
|
||||
self,
|
||||
items_count: int = 10,
|
||||
sep: str = ''
|
||||
) -> None:
|
||||
self.sep = sep
|
||||
self.items = [BarItem(False) for _ in range(items_count)]
|
||||
|
||||
def start(self, update_time: float = 0) -> None:
|
||||
"""After call this function program will start infinity loop"""
|
||||
while True:
|
||||
start = time()
|
||||
for i in range(len(self.items)):
|
||||
self[i].update()
|
||||
self.write()
|
||||
finish = time()
|
||||
sleep_time = update_time - (finish - start)
|
||||
sleep(0 if sleep_time < 0 else sleep_time)
|
||||
|
||||
def __getitem__(
|
||||
self,
|
||||
key: int
|
||||
) -> BarItem:
|
||||
return self.items[key]
|
||||
|
||||
def __setitem__(
|
||||
self,
|
||||
key: int,
|
||||
value: BarItem
|
||||
) -> None:
|
||||
self.items[key] = value
|
||||
|
||||
def __len__(self) -> int:
|
||||
return len(self.items)
|
||||
|
||||
def write(self, reversed: bool = True) -> None:
|
||||
out = ' ' + ''.join(
|
||||
[str(self[i]) + ' / ' for i in range(len(self))
|
||||
if self[i]
|
||||
]
|
||||
)[:-3] + ' '
|
||||
os.system(f"xsetroot -name \"{out}\"")
|
|
@ -1,125 +0,0 @@
|
|||
from subprocess import CalledProcessError
|
||||
import psutil
|
||||
from datetime import datetime
|
||||
from dwmbar.other import get_command_out
|
||||
|
||||
|
||||
class BarItem:
|
||||
def __init__(
|
||||
self,
|
||||
filled: bool = True
|
||||
) -> None:
|
||||
self.filled = bool(filled)
|
||||
self.out = ''
|
||||
|
||||
def update(self) -> None:
|
||||
pass
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.out
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
return self.filled
|
||||
|
||||
|
||||
class TimeItem(BarItem):
|
||||
def update(self) -> None:
|
||||
#
|
||||
now = datetime.now()
|
||||
if now.strftime("%p") == "AM":
|
||||
self.out = " "
|
||||
else:
|
||||
self.out = " "
|
||||
self.out += datetime.now().strftime("%I:%M")
|
||||
|
||||
|
||||
class RAMItem(BarItem):
|
||||
def __init__(self) -> None:
|
||||
"""RAM in G"""
|
||||
super().__init__(True)
|
||||
self.divider = 2**30
|
||||
self.total = round(psutil.virtual_memory()[0] / self.divider, 1)
|
||||
|
||||
def update(self) -> None:
|
||||
used = round(psutil.virtual_memory()[3] / self.divider, 1)
|
||||
self.out = f" {used}G"
|
||||
|
||||
|
||||
class LayoutItem(BarItem):
|
||||
def update(self) -> None:
|
||||
self.out = ' ' + get_command_out(
|
||||
"setxkbmap -query | grep layout"
|
||||
).split()[-1].upper()
|
||||
|
||||
|
||||
class CPUUsageItem(BarItem):
|
||||
def update(self) -> None:
|
||||
usage = psutil.cpu_percent()
|
||||
usage = f"{usage}" if usage % 1 else f"{int(usage)}.0"
|
||||
self.out = f" {usage:0>4}%"
|
||||
|
||||
|
||||
class DiskUsageItem(BarItem):
|
||||
def __init__(self, divider: int = 10**9) -> None:
|
||||
super().__init__(True)
|
||||
"""Disk in GB"""
|
||||
self.divider = 10**9
|
||||
self.total = round(psutil.disk_usage('/').total / self.divider, 1)
|
||||
|
||||
def update(self) -> None:
|
||||
used = round(psutil.disk_usage('/').used / self.divider, 1)
|
||||
self.out = F" {used}G/{self.total}G"
|
||||
|
||||
|
||||
class BatteryItem(BarItem):
|
||||
def __init__(self, hide_if_full: bool = False) -> None:
|
||||
super().__init__(True)
|
||||
# self.hide_if_full = hide_if_full
|
||||
|
||||
def update(self) -> None:
|
||||
battery = psutil.sensors_battery()
|
||||
# plugged = battery.power_plugged
|
||||
percent = round(battery.percent)
|
||||
# self.out = f" {'#' if plugged else '*'}{percent}%"
|
||||
self.out = f" {percent}%"
|
||||
# self.filled = False if self.hide_if_full and percent == 100 else True
|
||||
|
||||
|
||||
class VolumeItem(BarItem):
|
||||
def update(self) -> None:
|
||||
volume = get_command_out(
|
||||
"amixer get Master | awk -F'[][]' 'END{ print $4\":\"$2 }'"
|
||||
)
|
||||
self.out = " " + volume[volume.find(":") + 1:-1]
|
||||
|
||||
|
||||
class MusicItem(BarItem):
|
||||
def update(self) -> None:
|
||||
try:
|
||||
status = get_command_out("cmus-remote -Q")
|
||||
except CalledProcessError:
|
||||
self.out = " cmus"
|
||||
return
|
||||
if "file" not in status:
|
||||
self.out = " cmus"
|
||||
return
|
||||
for var in status.split("\n"):
|
||||
args = var.split()
|
||||
if not args:
|
||||
continue
|
||||
match args[0]:
|
||||
case "status":
|
||||
if args[1] == "playing":
|
||||
self.out = ""
|
||||
else:
|
||||
self.out = ""
|
||||
case "file":
|
||||
filename = var[var.rfind("/") + 1:var.rfind(".")]
|
||||
self.out += " " + filename
|
||||
|
||||
|
||||
class InfoItem(BarItem):
|
||||
def __init__(self, text: str) -> None:
|
||||
super().__init__()
|
||||
self.out = text
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
import subprocess
|
||||
|
||||
|
||||
def get_command_out(command: str) -> None:
|
||||
return subprocess.check_output(
|
||||
command,
|
||||
shell=True
|
||||
).decode("utf-8")
|
|
@ -1,33 +0,0 @@
|
|||
import subprocess
|
||||
import os
|
||||
import json
|
||||
|
||||
|
||||
def show_command_out(command: str) -> str:
|
||||
return subprocess.check_output(
|
||||
command,
|
||||
shell=True
|
||||
).decode("utf-8")
|
||||
|
||||
|
||||
def main():
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(f"{path}/dictionary.json") as file:
|
||||
dictionary = json.load(file)
|
||||
dictionary_list = [x for x in dictionary]
|
||||
|
||||
key = show_command_out(
|
||||
'echo "{}"\
|
||||
| dmenu -l 20 -p \"Select alias\"'.format(''.join([f'{x}\n' for x
|
||||
in dictionary_list])[:-1])
|
||||
).strip()
|
||||
|
||||
try:
|
||||
out = dictionary[key]
|
||||
except KeyError:
|
||||
return
|
||||
os.system(f"echo \"{out}\" | xclip -selection clipboard -r")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,10 +0,0 @@
|
|||
worried
|
||||
thinking
|
||||
shrug
|
||||
angry
|
||||
angrysight
|
||||
cuddles
|
||||
happy
|
||||
crying
|
||||
dancing
|
||||
confused
|
|
@ -1,18 +0,0 @@
|
|||
from random import choice
|
||||
|
||||
|
||||
def main() -> None:
|
||||
SIZE = 64
|
||||
ALPHABET = (
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"0123456789!@#$%^&*()[]{},."
|
||||
)
|
||||
|
||||
out = ''
|
||||
for _ in range(SIZE):
|
||||
out += choice(ALPHABET)
|
||||
print(out)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,28 +0,0 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
states = ["us", "ru"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
state = states[1]
|
||||
if os.path.exists("/tmp/layout.json"):
|
||||
with open("/tmp/layout.json") as f:
|
||||
state = json.load(f)["layout"]
|
||||
for i, val in enumerate(states):
|
||||
if val == state:
|
||||
state = states[(i + 1) % len(states)]
|
||||
break
|
||||
with open("/tmp/layout.json", 'w') as f:
|
||||
json.dump({"layout": state}, f, indent=4)
|
||||
os.system(f"setxkbmap {state}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) == 1:
|
||||
main()
|
||||
else:
|
||||
if "-s" in sys.argv:
|
||||
os.system(f"setxkbmap {states[0]}")
|
BIN
dwmscripts/out
BIN
dwmscripts/out
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB |
|
@ -1,36 +0,0 @@
|
|||
import psutil
|
||||
from pypresence import Presence
|
||||
import time
|
||||
|
||||
|
||||
def main() -> None:
|
||||
client_id = '1149335280072020078'
|
||||
RPC = Presence(client_id, pipe=0)
|
||||
RPC.connect()
|
||||
|
||||
start_time = psutil.boot_time()
|
||||
while True:
|
||||
# waiting = time.time() - start_time
|
||||
# minutes = waiting // 60
|
||||
# hours = minutes // 60
|
||||
# minutes = minutes % 60
|
||||
# waiting_days = int(time.time() - start_time) // 60 // 60 // 24
|
||||
waiting_days = int(time.time() - start_time) // 60 // 60 // 24
|
||||
# state=f"{int(hours):02}:{int(minutes):02}:{int(waiting % 60):02}",
|
||||
RPC.update(
|
||||
# details=details_list[i1],
|
||||
state=f"{waiting_days} days,",
|
||||
large_image="superpuper",
|
||||
large_text="This is a picture, isn't it?",
|
||||
buttons=[{
|
||||
"label": "This is not rickroll",
|
||||
"url": "https://goo.su/eriA6eD"
|
||||
}],
|
||||
start=start_time
|
||||
)
|
||||
RPC.update
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,74 +0,0 @@
|
|||
import os
|
||||
from random import choice
|
||||
# from requests import get
|
||||
|
||||
INDEX_HTML = "/home/naki/server/index.html"
|
||||
SERVER_PATH = "/home/naki/server/a/"
|
||||
LULS_PATH = "/home/naki/server/luls/"
|
||||
|
||||
RANDOM_SIZE = 5
|
||||
RANDOM_ALPHABET = (
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"0123456789"
|
||||
)
|
||||
|
||||
|
||||
def gen_random(size, alphabet) -> str:
|
||||
out = ''
|
||||
for _ in range(size):
|
||||
out += choice(alphabet)
|
||||
return out
|
||||
|
||||
|
||||
def main() -> None:
|
||||
images = next(os.walk(SERVER_PATH), (None, None, []))[2]
|
||||
# images = list(map(int, [image[3:-4] for image in images]))
|
||||
images = [image[:-4] for image in images]
|
||||
# out = max(images) + 1 if images else 0
|
||||
name = ''
|
||||
while True:
|
||||
name = gen_random(RANDOM_SIZE, RANDOM_ALPHABET)
|
||||
if name not in images:
|
||||
break
|
||||
os.system(f"/home/naki/dwmscripts/scrotpy.sh '{SERVER_PATH + name + '.png'}'")
|
||||
|
||||
# os.system(
|
||||
# f"flameshot gui --raw > {SERVER_PATH}img{out}.png"
|
||||
# )
|
||||
|
||||
# os.system(
|
||||
# f"flameshot gui --raw > {SERVER_PATH}{name}.png"
|
||||
# )
|
||||
|
||||
ip = "nakidai.ddns.net" # get('https://api.ipify.org').content.decode('utf8')
|
||||
|
||||
os.system(
|
||||
f"echo \"http://{ip}/a/{name}.png\" |"
|
||||
f" xclip -selection clipboard -r"
|
||||
)
|
||||
|
||||
with open(INDEX_HTML, 'w') as f:
|
||||
f.write(f"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Nakidai Perumenei</title>
|
||||
</head>
|
||||
<body>
|
||||
<h6>Latest screenshot:<h6>
|
||||
<tt>
|
||||
https://{ip}/a/{name}.png
|
||||
</tt>
|
||||
<h6>Cool things:<h6>
|
||||
<code>
|
||||
{"<br>".join([f"https://{ip}/luls/{img}<br>"
|
||||
for img in os.listdir(LULS_PATH)])}
|
||||
</code>
|
||||
</body>
|
||||
</html>""")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,7 +0,0 @@
|
|||
scrot -o /tmp/scrot.png
|
||||
feh -F /tmp/scrot.png &
|
||||
feh_pid=$!
|
||||
scrot --select '/home/naki/pic/screenshots/%F_%T_$wx$h.png' -e 'xclip -selection clipboard -target image/png -i $f'
|
||||
kill $feh_pid
|
||||
# flameshot gui --raw | xclip -selection clipboard -target image/png
|
||||
# maim -u | feh -F - & sleep 1 && maim -s | xclip -selection clipboard -target image/png && kill $!
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
scrot -s -f -o $1
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import dwmbar
|
||||
|
||||
|
||||
def main() -> None:
|
||||
# kernel_ver = dwmbar.get_command_out("uname -r")[:-1]
|
||||
|
||||
bar = dwmbar.Bar()
|
||||
bar[9] = dwmbar.modules.TimeItem()
|
||||
bar[8] = dwmbar.modules.RAMItem()
|
||||
# bar[7] = dwmbar.modules.DiskUsageItem()
|
||||
# bar[6] = dwmbar.modules.CPUUsageItem()
|
||||
bar[5] = dwmbar.modules.BatteryItem(True)
|
||||
|
||||
# bar[1] = dwmbar.modules.InfoItem(kernel_ver)
|
||||
bar[2] = dwmbar.modules.VolumeItem()
|
||||
bar[1] = dwmbar.modules.LayoutItem()
|
||||
bar[0] = dwmbar.modules.MusicItem()
|
||||
bar.start(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1 +0,0 @@
|
|||
sleep 1 && xset -display :0.0 dpms force off
|
Loading…
Reference in New Issue