1
0
Fork 0

Add syncthing ignore generator

main
Ambrose Chua 2022-07-08 13:31:45 +08:00
parent b1b1a04793
commit d63fdda2a2
3 changed files with 77 additions and 7 deletions

View File

@ -46,13 +46,21 @@ output * bg ~/.local/wallpaper/default.jpg fill
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.
set $swaylock 'swaylock -f --color 000000 --font "IBM Plex Sans" --image ~/.local/wallpaper/default.jpg'
set $dpms_on 'swaymsg "output * dpms on"'
set $dpms_off 'swaymsg "output * dpms off"'
exec swayidle -w \
timeout 300 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
timeout 310 'swaylock -f --color 000000 --font "IBM Plex Sans" --image ~/.local/wallpaper/default.jpg' \
before-sleep 'swaylock -f --color 000000 --font "IBM Plex Sans" --image ~/.local/wallpaper/default.jpg' \
timeout 1200 'systemctl suspend'
bindsym $mod+Pause exec swaylock -f --color 000000 --font "IBM Plex Sans" --image ~/.local/wallpaper/default.jpg
lock $swaylock \
timeout 10 '' \
resume $dpms_on \
timeout 300 $dpms_off \
resume $dpms_off \
timeout 360 $swaylock \
timeout 1200 'systemctl suspend' \
after-resume $dpms_on
bindsym $mod+Pause exec $swaylock
bindsym XF86ScreenSaver exec $swaylock; exec $dpms_off
bindsym $mod+Shift+Ctrl+p exec $swaylock; exec $dpms_off
### Input configuration
#
@ -84,7 +92,7 @@ input type:pointer {
natural_scroll enabled
}
# Disable pointer and touchpad
bindsym $mod+p input type:pointer events toggle enabled disabled
bindsym $mod+p input type:pointer events toggle enabled disabled; input type:keyboard events enabled
### Key bindings
#

59
.local/bin/stignore-gen Normal file
View File

@ -0,0 +1,59 @@
from typing import Optional, Iterable
from pathlib import Path
from argparse import ArgumentParser
def resolve(parent: Path, line: str) -> Iterable[str]:
if line.startswith("#") or len(line.strip()) == 0:
return
negate = line.startswith("!")
path = line.removeprefix("!").strip()
absolute = "/" in line.removesuffix("/")
prefix = ""
if negate:
prefix += "!"
else:
if (
"target" in path
or "generated" in path
or "output" in path
or "build" in path
or "node_modules" in path
):
prefix += "(?d)"
yield "// " + str(parent) + ": " + line.strip()
if absolute:
yield prefix + str(parent) + "/" + path.removeprefix("/")
else:
yield prefix + str(parent) + "/" + path.removeprefix("/")
yield prefix + str(parent) + "/**/" + path.removeprefix("/")
def scan(directory: Path) -> Iterable[str]:
for path in directory.rglob(".gitignore"):
parent = path.parent
if not path.is_file():
continue
with open(path, "r") as f:
for line in f:
yield from resolve(parent, line)
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(
"-w", "--write", action="store_const", const=True, default=False
)
args = parser.parse_args()
if args.write:
with open(".stignore.gen", "w") as f:
for line in scan(Path(".")):
f.write(line)
else:
for line in scan(Path(".")):
print(line)
# vim: set et ts=4 sw=4:

3
.zshrc
View File

@ -84,6 +84,9 @@ fi
if [[ -d "$HOME/.cargo" ]]; then
export PATH="$HOME/.cargo/bin:$PATH"
fi
if [[ -d "$HOME/.rbenv" ]]; then
export PATH="$HOME/.rbenv/bin:$PATH"
fi
# platform specific