Browse Source

Lotsofstuf

crash2
Geoffrey Frogeye 4 years ago
parent
commit
45c3bfe4d4
  1. 3
      config/autorandr/bg
  2. 10
      config/i3/config
  3. 4
      config/khard/khard.conf
  4. 5
      config/lemonbar/display.py
  5. 6
      config/lemonbar/providers.py
  6. 13
      config/lemonbar/requirements.txt
  7. 5
      config/lemonbar/updaters.py
  8. 1
      config/systemd/user/default.target.wants/syncthing.service
  9. 6
      config/systemd/user/melfetch.service
  10. 10
      config/systemd/user/melfetch.timer
  11. 1
      config/systemd/user/timers.target.wants/melfetch.timer
  12. 22
      scripts/install-prefs
  13. 26
      scripts/mel
  14. 115
      scripts/melConf
  15. 2
      scripts/rankmirrors
  16. 4
      scripts/showKeyboardLayout

3
config/autorandr/bg

@ -1,3 +1,4 @@
https://i.imgur.com/yVtVucs.jpg # Doctor Who Series 11
# Derivate of these ones https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-230622.png
https://geoffrey.frogeye.fr/files/backgrounds/VertBleu.png
# https://geoffrey.frogeye.fr/files/backgrounds/VertBleu.png
# https://geoffrey.frogeye.fr/files/backgrounds/BleuVert.png

10
config/i3/config

@ -61,6 +61,7 @@ bindsym $mod+F7 exec pactl suspend-sink @DEFAULT_SINK@ 1; exec pactl suspend-sin
bindsym XF86AudioPrev exec mpc prev
bindsym XF86AudioPlay exec mpc toggle
bindsym XF86AudioNext exec mpc next
bindsym $mod+F10 exec ~/.scripts/showKeyboardLayout
bindsym $mod+F11 exec urxvtc -e 'pacmixer'
bindsym $mod+F12 exec urxvtc -e 'pacmixer'
@ -252,6 +253,13 @@ bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exit
# Set shut down, restart and locking features
set $mode_kblock Keyboard lock
mode "$mode_kblock" {
bindsym $mod+Shift+Escape mode "$mode_kblock"
}
bindsym $mod+Shift+Escape mode "$mode_kblock"
# Set shut down, restart and locking features
set $locker $HOME/.config/i3/lock
set $mode_system [L] Vérouillage [E] Déconnexion [S] Veille [H] Hibernation [R] Redémarrage [P] Extinction
@ -347,7 +355,7 @@ set_from_resource $color15 i3wm.color15 #cfd0c2
# Inactivity settings
exec --no-startup-id xautolock -time 10 -locker 'xset dpms force standby' -killtime 1 -killer '$locker'
bindsym $mod+F1 exec --no-startup-id xset dpms force off
bindsym $mod+F1 exec --no-startup-id sh -c "sleep .25 && xset dpms force off"
bindsym $mod+F4 exec --no-startup-id xautolock -disable
bindsym $mod+F5 exec --no-startup-id xautolock -enable

4
config/khard/khard.conf

@ -8,8 +8,8 @@ path = ~/.vdirsyncer/contacts/contacts/
[general]
debug = no
default_action = list
editor = vim
merge_editor = vimdiff
editor = nvim
merge_editor = nvim
[contact table]
# display names by first or last name: first_name / last_name

5
config/lemonbar/display.py

@ -9,6 +9,7 @@ import signal
import subprocess
import logging
import coloredlogs
import updaters
coloredlogs.install(level='DEBUG', fmt='%(levelname)s %(message)s')
log = logging.getLogger()
@ -23,6 +24,7 @@ log = logging.getLogger()
# TODO Use default colors of lemonbar sometimes
# TODO Adapt bar height with font height
# TODO OPTI Static text objects that update its parents if modified
# TODO OPTI Updater locks, do not LB screen util every updater finished
class BarGroupType(enum.Enum):
@ -118,7 +120,6 @@ class Bar:
Bar.actionsF2H[function] = handle
Bar.actionsH2F[handle] = function
log.debug("Registered action {} → {}".format(handle, function))
return handle
@staticmethod
@ -292,8 +293,10 @@ class SectionThread(threading.Thread):
ANIMATION_START = 0.025
ANIMATION_STOP = 0.001
ANIMATION_EVOLUTION = 0.9
def run(self):
while Section.somethingChanged.wait():
updaters.notBusy.wait()
Section.updateAll()
animTime = self.ANIMATION_START
frameTime = time.perf_counter()

6
config/lemonbar/providers.py

@ -488,10 +488,14 @@ class NotmuchUnreadProvider(ColorCountsSection, InotifyUpdater):
queryStr = 'folder:/{}/ and tag:unread'.format(account)
query = notmuch.Query(db, queryStr)
nbMsgs = query.count_messages()
if account == 'frogeye':
global q
q = query
print(489, self.dir, queryStr, nbMsgs)
if nbMsgs < 1:
continue
counts.append((nbMsgs, self.colors[account]))
db.close()
# db.close()
return counts
def __init__(self, dir='~/.mail/', theme=None):

13
config/lemonbar/requirements.txt

@ -0,0 +1,13 @@
coloredlogs==10.0
enum-compat==0.0.2
humanfriendly==4.16.1
i3ipc==1.6.0
ifaddr==0.1.4
ipaddress==1.0.22
psutil==5.4.7
pulsectl==18.8.0
pyinotify==0.9.6
python-mpd2==1.0.0
python-uinput==0.11.2
yoke==0.1.1
zeroconf==0.21.3

5
config/lemonbar/updaters.py

@ -16,12 +16,14 @@ log = logging.getLogger()
# TODO Sync bar update with PeriodicUpdater updates
notBusy = threading.Event()
class Updater:
@staticmethod
def init():
PeriodicUpdater.init()
InotifyUpdater.init()
notBusy.set()
def updateText(self, text):
print(text)
@ -49,15 +51,18 @@ class PeriodicUpdaterThread(threading.Thread):
# TODO Sync with system clock
counter = 0
while True:
notBusy.set()
if PeriodicUpdater.intervalsChanged \
.wait(timeout=PeriodicUpdater.intervalStep):
# ↑ sleeps here
notBusy.clear()
PeriodicUpdater.intervalsChanged.clear()
counter = 0
for providerList in PeriodicUpdater.intervals.copy().values():
for provider in providerList.copy():
provider.refreshData()
else:
notBusy.clear()
counter += PeriodicUpdater.intervalStep
counter = counter % PeriodicUpdater.intervalLoop
for interval in PeriodicUpdater.intervals.keys():

1
config/systemd/user/default.target.wants/syncthing.service

@ -0,0 +1 @@
/usr/lib/systemd/user/syncthing.service

6
config/systemd/user/melfetch.service

@ -0,0 +1,6 @@
[Unit]
Description=Meh mail client new mail fetcher
[Service]
Type=oneshot
ExecStart=/home/geoffrey/.scripts/mel fetch

10
config/systemd/user/melfetch.timer

@ -0,0 +1,10 @@
[Unit]
Description=Meh mail client fetcher timer
[Timer]
OnBootSec=2m
OnUnitActiveSec=5m
Unit=melfetch.service
[Install]
WantedBy=timers.target

1
config/systemd/user/timers.target.wants/melfetch.timer

@ -0,0 +1 @@
/home/geoffrey/.config/systemd/user/melfetch.timer

22
scripts/install-prefs

@ -233,10 +233,10 @@ if [ $GUI == 1 ]; then
# Desktop manager
inst dunst feh i3-wm i3lock numlockx qutebrowser rofi rxvt-unicode scrot trayer unclutter xautolock xclip
if [ $ARCH == 1 ]; then
inst xorg-xinit xorg-xbacklight
inst xorg-xinit xorg-xbacklight ttf-dejavu
altInst lemonbar-xft-git autorandr-git keynav-enhanced pacmixer rofi-pass
elif [ $DEBIAN == 1 ]; then
# TODO autorandr pacmixer rofi-pass
# TODO autorandr pacmixer rofi-pass ttf-dejavu
inst lemonbar keynav xbacklight
fi
@ -257,12 +257,13 @@ fi
if [ $EXTRA == 1 ]; then
# Extra dev (not on mobile though ^^)
if [ $TERMUX == 0 ]; then
inst cmake clang llvm ccache python-pip
inst cmake clang llvm ccache python-pip gdb
fi
# Extra CLI
inst ffmpeg optipng syncthing mutt notmuch mbsync jq
inst unzip unrar jdupes bedup
inst ffmpeg optipng syncthing mutt notmuch mbsync jq lynx
inst unzip unrar jdupes bedup p7zip
inst youtube-dl megatools speedtest-cli
systemdUserUnit syncthing
if [ $ARCH == 1 ]; then
insta pandoc youtube-dl translate-shell imagemagick
@ -282,13 +283,22 @@ if [ $EXTRA == 1 ]; then
# TODO Others
fi
# FPGA goodness
if [ $ARCH == 1 ]; then
inst iverilog
altInst ghdl
fi
# Extra GUI
if [ $GUI == 1 ]; then
inst vlc gimp mpd thunar musescore evince pdfpc texlive-{most,lang}
inst vlc gimp inkscape mpd thunar musescore evince pdfpc texlive-{most,lang}
if [ $ARCH == 1 ]; then
inst simplescreenrecorder mpc
altInst vimpc-git ashuffle-git ttf-emojione-color
# FPGA goodness
inst gtkwave
fi
# TODO Others

26
scripts/mel

@ -313,29 +313,6 @@ def applyMsgs(queryStr, action, *args, showProgress=False, write=False, closeDb=
return nbMsgs
# def update_polybar_status():
def update_polybar_status(*args, **kwargs):
log.info("Updating polybar status")
accountsList = sorted(ACCOUNTS.keys())
print(accountsList)
open_database()
statusArr = []
for account in accountsList:
queryStr = 'folder:/{}/ and tag:unread'.format(account)
query = notmuch.Query(db, queryStr)
nbMsgs = query.count_messages()
if nbMsgs < 1:
continue
color = config[account]['color']
statusAccStr = '%{F' + color + '}' + str(nbMsgs) + '%{F-}'
statusArr.append(statusAccStr)
close_database()
statusStr = ('_' + ' '.join(statusArr)) if len(statusArr) else '\n'
statusPath = os.path.expanduser("~/.cache/mutt/status") # TODO Better
with open(statusPath, 'w') as f:
f.write(statusStr)
# statusPath = os.path.expanduser("~/.cache/mel/polybarstatus") # TODO Better
def notify_msg(msg):
log.info("Sending notification for {}".format(msg))
subject = msg.get_header("subject")
@ -448,7 +425,7 @@ def read_msg(msg):
# Headers
for key in INTERESTING_HEADERS:
for key in INTERESTING_HEADERS:
val = mail.get(key)
if val:
val = format_header_value(val)
@ -560,7 +537,6 @@ if __name__ == "__main__":
# Notify
notify_all()
update_polybar_status()
# Tag new mails
applyMsgs('tag:unprocessed', retag_msg, showProgress=True, write=True)

115
scripts/melConf

@ -11,6 +11,7 @@ import sys
# TODO Find config file from XDG
# TODO Signature file
# TODO Write ~/.mail/[mailbox]/color file if required by sth?
# TODO Write in .config or .cache /mel
# TODO Fix IMAPS with mbsync
configPath = os.path.join(os.path.expanduser('~'), '.config', 'mel', 'accounts.conf')
@ -26,6 +27,17 @@ SERVER_DEFAULTS = {
"smtp": {"port": 587, "starttls": True},
}
SERVER_ITEMS = {"host", "port", "user", "pass", "starttls"}
ACCOUNT_DEFAULTS = {
"color": "#FFFFFF",
"color16": "0",
# "colormutt": "white",
"inboxfolder": "INBOX",
"archivefolder": "Archive",
"draftsfolder": "Drafts",
"sentfolder": "Sent",
"spamfolder": "Spam",
"trashfolder": "Trash",
}
# Reading sections
accounts = dict()
@ -59,6 +71,14 @@ for name in config.sections():
continue
data[key] = section[key]
for k, v in config['DEFAULT'].items():
if k not in data:
data[k] = v
for k, v in ACCOUNT_DEFAULTS.items():
if k not in data:
data[k] = v
mails.add(section["from"])
if "alternatives" in section:
for alt in section["alternatives"].split(";"):
@ -163,8 +183,8 @@ for name, account in accounts.items():
secconf += "\nCertificateFile {certificate}".format(**account)
imappassEscaped = account["imappass"].replace("\\", "\\\\")
mbsyncStr += MBSYNC_ACCOUNT.format(**account, secconf=secconf, imappassEscaped=imappassEscaped)
msbsyncFilepath = os.path.join(os.path.expanduser('~'), '.mbsyncrc')
with open(msbsyncFilepath, 'w') as f:
mbsyncFilepath = os.path.join(os.path.expanduser('~'), '.mbsyncrc')
with open(mbsyncFilepath, 'w') as f:
f.write(mbsyncStr)
# msmtp
@ -188,8 +208,8 @@ tls on
msmtpStr = MSMTP_BEGIN
for name, account in accounts.items():
msmtpStr += MSMTP_ACCOUNT.format(**account)
msbsyncFilepath = os.path.join(os.path.expanduser('~'), '.msmtprc')
with open(msbsyncFilepath, 'w') as f:
mbsyncFilepath = os.path.join(os.path.expanduser('~'), '.msmtprc')
with open(mbsyncFilepath, 'w') as f:
f.write(msmtpStr)
@ -221,7 +241,90 @@ other_email = mails.copy()
other_email.remove(general["main"]["from"])
other_email = ";".join(other_email)
notmuchStr = NOTMUCH_BEGIN.format(**general, other_email=other_email)
msbsyncFilepath = os.path.join(os.path.expanduser('~'), '.notmuchrc')
with open(msbsyncFilepath, 'w') as f:
mbsyncFilepath = os.path.join(os.path.expanduser('~'), '.notmuchrc')
with open(mbsyncFilepath, 'w') as f:
f.write(notmuchStr)
# mutt (temp)
## mailboxes
MAILBOXES_BEGIN = "mailboxes"
mailboxesStr = MAILBOXES_BEGIN
for name, account in accounts.items():
lines = "-" * (20 - len(name))
mailboxesStr += f' "+{name}{lines}"'
for root, dirs, files in os.walk(account['storage']):
if "cur" not in dirs or "new" not in dirs or "tmp" not in dirs:
continue
assert root.startswith(storageFull)
path = root[len(storageFull)+1:]
mailboxesStr += f' "+{path}"'
mailboxesStr += "\n"
mailboxesFilepath = os.path.join(os.path.expanduser('~'), '.mutt/mailboxes')
with open(mailboxesFilepath, 'w') as f:
f.write(mailboxesStr)
## accounts
# TODO html mails
MUTT_ACCOUNT = """set from = "{from}"
set sendmail = "/usr/bin/msmtp -a {account}"
set realname = "{name}"
set spoolfile = "+{account}/{inboxfolder}"
set mbox = "+{account}/{archivefolder}"
set postponed = "+{account}/{draftsfolder}"
set record = "+{account}/{sentfolder}"
set trash = "+{account}/{trashfolder}"
set signature = "~/.mutt/accounts/{account}.sig"
set content_type = "text/plain"
set sig_dashes = yes
color status {colormutt} default
macro index D \\
"<clear-flag>N<save-message>+{account}/{trashfolder}<enter>" \\
"move message to the trash"
macro index S \\
"<clear-flag>N<save-message>+{account}/{spamfolder}<enter>" \\
"mark message as spam"
# vim: syntax=muttrc
"""
for name, account in accounts.items():
muttStr = MUTT_ACCOUNT.format(**account)
# Config
muttFilepath = os.path.join(os.path.expanduser('~'), f'.mutt/accounts/{name}')
with open(muttFilepath, 'w') as f:
f.write(muttStr)
# Signature
sigStr = account.get("sig", account.get("name", ""))
sigFilepath = os.path.join(os.path.expanduser('~'), f'.mutt/accounts/{name}.sig')
with open(sigFilepath, 'w') as f:
f.write(sigStr)
MUTT_SELECTOR = """
set folder = "{storage}"
source ~/.mutt/mailboxes
source ~/.mutt/accounts/{main[account]}
{hooks}
source ~/.mutt/custom
# vim: syntax=muttrc
"""
selectStr = ""
hooks = ""
for name, account in accounts.items():
hooks += f"folder-hook {name}/* source ~/.mutt/accounts/{name}\n"
selectStr += MUTT_SELECTOR.format(**general, hooks=hooks)
selectFilepath = os.path.join(os.path.expanduser('~'), '.mutt/muttrc')
with open(selectFilepath, 'w') as f:
f.write(selectStr)

2
scripts/rankmirrors

@ -0,0 +1,2 @@
#!/usr/bin/env bash
egrep -o 'Server = .+' /etc/pacman.d/mirrorlist.pacnew | /usr/bin/rankmirrors-n6 - > /etc/pacman.d/mirrorlist

4
scripts/showKeyboardLayout

@ -0,0 +1,4 @@
#!/usr/bin/bash
layout=`setxkbmap -query | grep layout | tr -s ' ' | cut -d ' ' -f2`
variant=`setxkbmap -query | grep variant | tr -s ' ' | cut -d ' ' -f2`
gkbd-keyboard-display -l ${layout}$'\t'${variant}
Loading…
Cancel
Save