Lotsofstuf

This commit is contained in:
Geoffrey Frogeye 2018-10-14 16:59:49 +02:00
parent 3d24d97d51
commit 45c3bfe4d4
16 changed files with 190 additions and 43 deletions

View File

@ -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 # 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 # https://geoffrey.frogeye.fr/files/backgrounds/BleuVert.png

View File

@ -61,6 +61,7 @@ bindsym $mod+F7 exec pactl suspend-sink @DEFAULT_SINK@ 1; exec pactl suspend-sin
bindsym XF86AudioPrev exec mpc prev bindsym XF86AudioPrev exec mpc prev
bindsym XF86AudioPlay exec mpc toggle bindsym XF86AudioPlay exec mpc toggle
bindsym XF86AudioNext exec mpc next bindsym XF86AudioNext exec mpc next
bindsym $mod+F10 exec ~/.scripts/showKeyboardLayout
bindsym $mod+F11 exec urxvtc -e 'pacmixer' bindsym $mod+F11 exec urxvtc -e 'pacmixer'
bindsym $mod+F12 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) # exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exit 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 shut down, restart and locking features
set $locker $HOME/.config/i3/lock set $locker $HOME/.config/i3/lock
set $mode_system [L] Vérouillage [E] Déconnexion [S] Veille [H] Hibernation [R] Redémarrage [P] Extinction 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 # Inactivity settings
exec --no-startup-id xautolock -time 10 -locker 'xset dpms force standby' -killtime 1 -killer '$locker' 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+F4 exec --no-startup-id xautolock -disable
bindsym $mod+F5 exec --no-startup-id xautolock -enable bindsym $mod+F5 exec --no-startup-id xautolock -enable

View File

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

View File

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

View File

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

View File

@ -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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -313,29 +313,6 @@ def applyMsgs(queryStr, action, *args, showProgress=False, write=False, closeDb=
return nbMsgs 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): def notify_msg(msg):
log.info("Sending notification for {}".format(msg)) log.info("Sending notification for {}".format(msg))
subject = msg.get_header("subject") subject = msg.get_header("subject")
@ -448,7 +425,7 @@ def read_msg(msg):
# Headers # Headers
for key in INTERESTING_HEADERS: for key in INTERESTING_HEADERS:
val = mail.get(key) val = mail.get(key)
if val: if val:
val = format_header_value(val) val = format_header_value(val)
@ -560,7 +537,6 @@ if __name__ == "__main__":
# Notify # Notify
notify_all() notify_all()
update_polybar_status()
# Tag new mails # Tag new mails
applyMsgs('tag:unprocessed', retag_msg, showProgress=True, write=True) applyMsgs('tag:unprocessed', retag_msg, showProgress=True, write=True)

View File

@ -11,6 +11,7 @@ import sys
# TODO Find config file from XDG # TODO Find config file from XDG
# TODO Signature file # TODO Signature file
# TODO Write ~/.mail/[mailbox]/color file if required by sth? # TODO Write ~/.mail/[mailbox]/color file if required by sth?
# TODO Write in .config or .cache /mel
# TODO Fix IMAPS with mbsync # TODO Fix IMAPS with mbsync
configPath = os.path.join(os.path.expanduser('~'), '.config', 'mel', 'accounts.conf') configPath = os.path.join(os.path.expanduser('~'), '.config', 'mel', 'accounts.conf')
@ -26,6 +27,17 @@ SERVER_DEFAULTS = {
"smtp": {"port": 587, "starttls": True}, "smtp": {"port": 587, "starttls": True},
} }
SERVER_ITEMS = {"host", "port", "user", "pass", "starttls"} 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 # Reading sections
accounts = dict() accounts = dict()
@ -59,6 +71,14 @@ for name in config.sections():
continue continue
data[key] = section[key] 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"]) mails.add(section["from"])
if "alternatives" in section: if "alternatives" in section:
for alt in section["alternatives"].split(";"): for alt in section["alternatives"].split(";"):
@ -163,8 +183,8 @@ for name, account in accounts.items():
secconf += "\nCertificateFile {certificate}".format(**account) secconf += "\nCertificateFile {certificate}".format(**account)
imappassEscaped = account["imappass"].replace("\\", "\\\\") imappassEscaped = account["imappass"].replace("\\", "\\\\")
mbsyncStr += MBSYNC_ACCOUNT.format(**account, secconf=secconf, imappassEscaped=imappassEscaped) mbsyncStr += MBSYNC_ACCOUNT.format(**account, secconf=secconf, imappassEscaped=imappassEscaped)
msbsyncFilepath = os.path.join(os.path.expanduser('~'), '.mbsyncrc') mbsyncFilepath = os.path.join(os.path.expanduser('~'), '.mbsyncrc')
with open(msbsyncFilepath, 'w') as f: with open(mbsyncFilepath, 'w') as f:
f.write(mbsyncStr) f.write(mbsyncStr)
# msmtp # msmtp
@ -188,8 +208,8 @@ tls on
msmtpStr = MSMTP_BEGIN msmtpStr = MSMTP_BEGIN
for name, account in accounts.items(): for name, account in accounts.items():
msmtpStr += MSMTP_ACCOUNT.format(**account) msmtpStr += MSMTP_ACCOUNT.format(**account)
msbsyncFilepath = os.path.join(os.path.expanduser('~'), '.msmtprc') mbsyncFilepath = os.path.join(os.path.expanduser('~'), '.msmtprc')
with open(msbsyncFilepath, 'w') as f: with open(mbsyncFilepath, 'w') as f:
f.write(msmtpStr) f.write(msmtpStr)
@ -221,7 +241,90 @@ other_email = mails.copy()
other_email.remove(general["main"]["from"]) other_email.remove(general["main"]["from"])
other_email = ";".join(other_email) other_email = ";".join(other_email)
notmuchStr = NOTMUCH_BEGIN.format(**general, other_email=other_email) notmuchStr = NOTMUCH_BEGIN.format(**general, other_email=other_email)
msbsyncFilepath = os.path.join(os.path.expanduser('~'), '.notmuchrc') mbsyncFilepath = os.path.join(os.path.expanduser('~'), '.notmuchrc')
with open(msbsyncFilepath, 'w') as f: with open(mbsyncFilepath, 'w') as f:
f.write(notmuchStr) 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 Normal file
View File

@ -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 Executable file
View File

@ -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}