11 Commits

  1. 1
      config/automatrop/host_vars/curacao.geoffrey.frogeye.fr
  2. 37
      config/automatrop/roles/software/tasks/main.yml
  3. 1
      config/automatrop/roles/software/templates/snippets/pm_dev_common.j2
  4. 1
      config/automatrop/roles/software/templates/snippets/pm_dev_php.j2
  5. 7
      config/automatrop/roles/software/templates/snippets/pm_dev_python.j2
  6. 7
      config/automatrop/roles/system/files/xorg/joystick.conf
  7. 4
      config/automatrop/roles/vim/templates/pluginlist.j2
  8. 3
      config/automatrop/roles/vim/templates/plugins/indent-blankline.j2
  9. 5
      config/automatrop/roles/vim/templates/plugins/nvim_lspconfig.j2
  10. 4
      config/automatrop/roles/vim/templates/plugins/telescope.j2
  11. 2
      config/automatrop/roles/vim/templates/plugins/ts-rainbow.j2
  12. 2
      config/inputrc
  13. 17
      config/scripts/arch-kexec
  14. 3
      config/scripts/bsh
  15. 23
      config/scripts/lestrte
  16. 21
      config/scripts/letrtes
  17. 2
      config/scripts/mel
  18. 49
      config/scripts/rssVideos
  19. 8
      config/scripts/smtpdummy

1
config/automatrop/host_vars/curacao.geoffrey.frogeye.fr

@ -6,6 +6,7 @@ dev_stuffs:
- network
- ansible
- docker
- php
software_full: yes
has_battery: yes
auto_numlock: yes

37
config/automatrop/roles/software/tasks/main.yml

@ -67,6 +67,14 @@
become: yes
when: arch_based
- name: Enable makepkg color
replace:
path: /etc/makepkg.conf
regexp: '^BUILDENV=(.+)!color(.+)$'
replace: 'BUILDENV=\1color\2'
become: yes
when: arch_based
- name: Enable makepkg ccache
replace:
path: /etc/makepkg.conf
@ -75,23 +83,33 @@
become: yes
when: arch_based
- name: Set makepkg MAKEFLAGS
- name: Remove -mtune from makepkg CFLAGS
replace:
path: /etc/makepkg.conf
regexp: '^#? *MAKEFLAGS=(.+)-j[0-9]+(.+)$'
replace: "MAKEFLAGS=\\1-j{{ j }}\\2"
regexp: '^#? *CFLAGS=(.+)-mtune=\S+\s(.*)$'
replace: "CFLAGS=\\1\\2"
become: yes
vars:
j: "{{ [ansible_processor_nproc - 1, 1] | max | int }}"
when: arch_based
tags: g
- name: Enable makepkg color
- name: Change -march to native from makepkg CFLAGS
replace:
path: /etc/makepkg.conf
regexp: '^BUILDENV=(.+)!color(.+)$'
replace: 'BUILDENV=\1color\2'
regexp: '^#? *CFLAGS=(.+)-march=\S+(\s)(.*)$'
replace: "CFLAGS=\\1-march=native\\2\\3"
become: yes
when: arch_based
tags: g
- name: Set makepkg MAKEFLAGS
replace:
path: /etc/makepkg.conf
regexp: '^#? *MAKEFLAGS=(.+)-j[0-9]+(.+)$'
replace: "MAKEFLAGS=\\1-j{{ j }}\\2"
become: yes
vars:
j: "{{ [ansible_processor_nproc - 1, 1] | max | int }}"
when: arch_based
- name: Enable pacman ParallelDownloads
lineinfile:
@ -161,6 +179,9 @@
notify: "software changed"
tags: softwarelist
- debug:
msg: "{{ packages }}"
- name: Install packages (Arch-based)
aur:
name: "{{ packages }}"

1
config/automatrop/roles/software/templates/snippets/pm_dev_common.j2

@ -11,3 +11,4 @@ highlight
{% endif %}
{# For nvim's :Telescope live_grep #}
ripgrep
{# EOF #}

1
config/automatrop/roles/software/templates/snippets/pm_dev_php.j2

@ -0,0 +1 @@
{# EOF #}

7
config/automatrop/roles/software/templates/snippets/pm_dev_python.j2

@ -1,9 +1,10 @@
mypy
{% if not arch_based %}
black
{# On arch it's installed as a dependency, also it's called python-black #}
{% endif %}
{% if arch_based %}
python-language-server
pyls-mypy
python-language-server-black
python-lsp-server
python-mypy-ls
python-lsp-black
{% endif %}

7
config/automatrop/roles/system/files/xorg/joystick.conf

@ -6,3 +6,10 @@ Section "InputClass"
Option "StartKeysEnabled" "False" #Disable mouse
Option "StartMouseEnabled" "False" #support
EndSection
# Same thing for DualShock 4 touchpad
Section "InputClass"
Identifier "ds4-touchpad"
Driver "libinput"
MatchProduct "Wireless Controller Touchpad"
Option "Ignore" "True"
EndSection

4
config/automatrop/roles/vim/templates/pluginlist.j2

@ -35,6 +35,7 @@ source ~/.config/vim/theme.vim
" Search/replace
{{ use_plugin('abolish') }}
{{ use_plugin('easy_align') }}
" Sourounding pairs
{{ use_plugin('surround') }}
@ -70,6 +71,9 @@ source ~/.config/vim/theme.vim
{% if variant == 'nvim' %}
{{ use_plugin('treesitter') }}
{{ use_plugin('ts-rainbow') }}
{# TODO
{{ use_plugin('indent-blankline') }}
#}
{% endif %}
" Snippets

3
config/automatrop/roles/vim/templates/plugins/indent-blankline.j2

@ -0,0 +1,3 @@
{# Show ident lines #}
{{ add_source('lukas-reineke/indent-blankline.nvim') -}}
let g:indent_blankline_char_highlight_list = ['Error', 'Function']

5
config/automatrop/roles/vim/templates/plugins/nvim_lspconfig.j2

@ -42,7 +42,10 @@ end
-- map buffer local keybindings when the language server attaches
local servers = {
{% if 'python' in dev_stuffs %}
"pyls",
"pylsp",
{% endif %}
{% if 'php' in dev_stuffs %}
"phpactor", -- Install this one manually https://phpactor.readthedocs.io/en/master/usage/standalone.html#global-installation
{% endif %}
}
for _, lsp in ipairs(servers) do

4
config/automatrop/roles/vim/templates/plugins/telescope.j2

@ -18,9 +18,9 @@ noremap gc <cmd>Telescope commands<cr>
noremap gr <cmd>Telescope lsp_references<cr>
noremap ga <cmd>Telescope lsp_code_actions<cr>
vnoremap ga <cmd>Telescope lsp_range_code_actions<cr>
noremap gq <cmd>Telescope lsp_document_diagnostics<cr>
noremap ge <cmd>Telescope lsp_document_diagnostics<cr>
noremap gE <cmd>Telescope lsp_workspace_diagnostics<cr>
noremap ge <cmd>Telescope lsp_definitions<cr>
noremap gd <cmd>Telescope lsp_definitions<cr>
lua << EOF
require('telescope').setup{

2
config/automatrop/roles/vim/templates/plugins/ts-rainbow.j2

@ -1,5 +1,5 @@
{# Randomly color parentheses pairs #}
{{add_source('p00f/nvim-ts-rainbow')-}}
{{ add_source('p00f/nvim-ts-rainbow') -}}
lua << EOF
require'nvim-treesitter.configs'.setup {
rainbow = {

2
config/inputrc

@ -25,6 +25,8 @@ set visible-stats off
$if mode=vi
# these are for vi-command mode
set keymap vi-command
"k": history-search-backward
"j": history-search-forward
"\e[A": history-search-backward
"\e[B": history-search-forward
Control-l: clear-screen

17
config/scripts/arch-kexec

@ -1,3 +1,18 @@
#!/usr/bin/env bash
sudo kexec -l /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --reuse-cmdline
set -euxo pipefail
# Set variables
name="${1:-linux}"
kernel="/boot/vmlinuz-$name"
initrd="/boot/initramfs-$name.img"
# Test if required files are present
[ -f $kernel ]
[ -f $initrd ]
command -v kexec &> /dev/null
# Configure the next kernel to load
sudo kexec -l $kernel --initrd=$initrd --reuse-cmdline
# Gracefully restart on the next kernel
sudo systemctl kexec

3
config/scripts/bsh

@ -18,7 +18,8 @@ then
# Copying files
grep -o '^[^#]*' ~/.config/shell/trimmed.bash > "${WORK}/.bashrc"
grep -o '^[^#]*' ~/.config/inputrc > "${WORK}/.inputrc"
grep -o '^[^"]*' ~/.config/vim/vimconfig.vim > "${WORK}/.vimrc"
# grep -o '^[^"]*' ~/.config/vim/vimconfig.vim > "${WORK}/.vimrc"
# TODO Above file doesn't work anymore with automatrop
#mkdir -p "${WORK}/terminfo/${TERM:0:1}"
#if [ -f "/usr/share/terminfo/${TERM:0:1}/${TERM}" ]
#then

23
config/scripts/lestrte

@ -3,26 +3,19 @@
import sys
import random
# maj = True
for line in sys.stdin:
nl = ""
word = ""
grace = True
for c in line:
if c.isalpha():
if grace:
nl += word
nl += c
word = ""
grace = False
else:
word += c
word += c
else:
wrd = list(word)
random.shuffle(wrd)
nl += "".join(wrd)
nl += c
if len(word) > 2:
wrd = list(word)[1:]
random.shuffle(wrd)
nl += word[0] + "".join(wrd)
else:
nl += word
word = ""
grace = True
nl += c
print(nl, end="")

21
config/scripts/letrtes

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import sys
import random
for line in sys.stdin:
nl = ""
word = ""
for c in line:
if c.isalpha():
word += c
else:
if len(word) > 3:
wrd = list(word)[1:-1]
random.shuffle(wrd)
nl += word[0] + "".join(wrd) + word[-1]
else:
nl += word
word = ""
nl += c
print(nl, end="")

2
config/scripts/mel

@ -678,7 +678,7 @@ class MelCLI:
Handles the user input and run asked operations.
"""
VERBOSITY_LEVELS = ["DEBUG", "INFO", "WARNING", "ERROR", "FATAL"]
VERBOSITY_LEVELS = ["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
def apply_msgs_input(
self,

49
config/scripts/rssVideos

@ -8,17 +8,16 @@ with the unread items (non-video links are ignored).
"""
# TODO Distribute this correclty, in the meanwhile please do
# pip install --user youtube-dl ConfigArgParse progressbar2
# pip install --user yt-dlp ConfigArgParse
# TODO Better logging (youtube-dl allow to pass loggers)
import sys
from typing import Dict, Set, Tuple
import urllib.request
import urllib.parse
import os
from xml.dom import minidom
import youtube_dl
import yt_dlp as youtube_dl
import configargparse
@ -95,18 +94,19 @@ def get_args() -> configargparse.Namespace:
return args
def get_links(args: configargparse.Namespace) -> Set[str]:
def get_links(args: configargparse.Namespace) -> list[str]:
"""
Read the feed XML, get the links
"""
links = set()
links = list()
with urllib.request.urlopen(args.feed) as request:
with minidom.parse(request) as xmldoc:
for item in xmldoc.getElementsByTagName("item"):
try:
linkNode = item.getElementsByTagName("link")[0]
link: str = linkNode.childNodes[0].data
links.add(link)
if link not in links:
links.append(link)
except BaseException as e:
print("Error while getting link from item:", e)
continue
@ -114,8 +114,8 @@ def get_links(args: configargparse.Namespace) -> Set[str]:
def get_video_infos(
args: configargparse.Namespace, ydl_opts: Dict, links: Set[str]
) -> Dict[str, Dict]:
args: configargparse.Namespace, ydl_opts: dict, links: list[str]
) -> dict[str, dict]:
"""
Filter out non-video links and store video download info
and associated filename
@ -148,8 +148,8 @@ def get_video_infos(
def get_downloaded_videos(
args: configargparse.Namespace, videosInfos: Dict[str, Dict]
) -> Tuple[Set[str], Set[str]]:
args: configargparse.Namespace, videosInfos: dict[str, dict]
) -> tuple[set[str], set[str]]:
videosDownloaded = set()
videosPartiallyDownloaded = set()
"""
@ -187,7 +187,7 @@ def get_downloaded_videos(
return videosDownloaded, videosPartiallyDownloaded
def get_tracked_videos(args: configargparse.Namespace, known: Set[str]) -> Set[str]:
def get_tracked_videos(args: configargparse.Namespace, known: set[str]) -> set[str]:
"""
Return videos previously downloaded (=tracked) amongst the unread videos.
This is stored in the tracking directory as empty extension-less files.
@ -220,6 +220,8 @@ def main() -> None:
print("→ Retrieveing RSS feed")
links = get_links(args)
# Oldest first
links = links[::-1]
print(f"→ Getting infos on {len(links)} unread articles")
videosInfos = get_video_infos(args, ydl_opts, links)
@ -236,8 +238,8 @@ def main() -> None:
markerPath = os.path.join(args.track, onlineFilename)
open(markerPath, "a").close()
videosToDownload: Set[str] = set()
videosReads: Set[str] = set()
videosToDownload: set[str] = set()
videosReads: set[str] = set()
for onlineFilename in videosInfos.keys():
# If the video was once downloaded but manually deleted,
# the marker should be left
@ -263,14 +265,19 @@ def main() -> None:
os.chdir(args.videos)
exit_code = 0
if not args.dryrun:
# TODO Progressbar one day maybe?
# We have all the info we need to make a reliable one
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
for onlineFilename in videosToDownload:
infos = videosInfos[onlineFilename]
# Really download
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
for onlineFilename, infos in videosInfos.items():
if onlineFilename not in videosToDownload:
continue
# Really download
if args.dryrun:
print(f"Would download {onlineFilename}")
else:
# Apparently that thing is transformed from a LazyList
# somewhere in the normal yt_dlp process
if isinstance(infos["thumbnails"], youtube_dl.utils.LazyList):
infos["thumbnails"] = infos["thumbnails"].exhaust()
try:
ydl.process_ie_result(infos, True, {})

8
config/scripts/smtpdummy

@ -9,6 +9,7 @@ import io
import pprint
import subprocess
import sys
import uuid
if __name__ == "__main__":
@ -72,6 +73,7 @@ if __name__ == "__main__":
if args.password:
password = args.password
args.password = "********"
mid = f"{uuid.uuid1()}@{args.helo}"
# Transmission content
@ -89,6 +91,7 @@ XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"""
From: {getattr(args, 'from')}
Subject: {args.subject}
To: {args.to}
Message-ID: {mid}
Hello there,
@ -141,7 +144,10 @@ Input arguments:
next = True
while next:
line = p.stdout.readline()
code = int(line[:3])
try:
code = int(line[:3])
except ValueError:
raise ValueError(f"Could not parse line: '{line.decode()}'")
success = code < 400
color = colorama.Fore.GREEN if success else colorama.Fore.RED
if not args.quiet:

Loading…
Cancel
Save