Push To Talk
Postes, Télégraphes et Téléphones
Petit Travail Tranquille
This commit is contained in:
Geoffrey Frogeye 2018-10-25 22:35:02 +02:00
parent b1b03e827f
commit f9849dfcfa
7 changed files with 111 additions and 9 deletions

View file

@ -542,12 +542,10 @@ class TaskWarriorProvider(StatefulSection, InotifyUpdater):
if urgency > 0:
total += urgency
t = Text()
maxi = round(maxi)
t.append(f"{maxi}")
t.append(f"{maxi:.1f}")
if self.showTotal:
total = round(total)
t.append(f" | {total}")
t.append(f" | {total:.1f}")
return t

View file

@ -0,0 +1,6 @@
[Unit]
Description=Taskwarrior synchronisation
[Service]
Type=oneshot
ExecStart=/usr/bin/task sync

View file

@ -0,0 +1,10 @@
[Unit]
Description=Taskwarrior synchronisation timer
[Timer]
OnBootSec=2m
OnUnitActiveSec=5m
Unit=tasksync.service
[Install]
WantedBy=timers.target

View file

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

View file

@ -1,4 +1,8 @@
#!/usr/bin/bash
# From https://stackoverflow.com/a/14736593
pdftk "$1" dump_data | grep NumberOfPages | awk '{print $2}'
for FILE in $*
do
printf "$FILE: "
pdftk "$FILE" dump_data | grep NumberOfPages | awk '{print $2}'
done

80
scripts/pushToTalk Normal file
View file

@ -0,0 +1,80 @@
#!/usr/bin/env python3
import sys
import pulsectl
from Xlib import X, XK, display
from Xlib.ext import record
from Xlib.protocol import rq
KEY = XK.XK_F7
def mute(state):
with pulsectl.Pulse('list-source') as pulse:
for source in pulse.source_list():
if source.port_active:
if source.mute != state:
pulse.mute(source, state)
print(f"{source.name} {'un' if not state else ''}muted")
mute(True)
local_dpy = display.Display()
record_dpy = display.Display()
def record_callback(reply):
if reply.category != record.FromServer:
return
if reply.client_swapped:
print("* received swapped protocol data, cowardly ignored")
return
if not len(reply.data) or reply.data[0] < 2:
# not an event
return
data = reply.data
while len(data):
event, data = rq.EventField(None).parse_binary_value(
data, record_dpy.display, None, None)
if event.type in [X.KeyPress, X.KeyRelease]:
keysym = local_dpy.keycode_to_keysym(event.detail, 0)
if keysym == KEY:
mute(event.type == X.KeyRelease)
# Check if the extension is present
if not record_dpy.has_extension("RECORD"):
print("RECORD extension not found")
sys.exit(1)
r = record_dpy.record_get_version(0, 0)
print("RECORD extension version %d.%d" %
(r.major_version, r.minor_version))
# Create a recording context; we only want key and mouse events
ctx = record_dpy.record_create_context(
0,
[record.AllClients],
[{
'core_requests': (0, 0),
'core_replies': (0, 0),
'ext_requests': (0, 0, 0, 0),
'ext_replies': (0, 0, 0, 0),
'delivered_events': (0, 0),
'device_events': (X.KeyPress, X.MotionNotify),
'errors': (0, 0),
'client_started': False,
'client_died': False,
}])
# Enable the context; this only returns after a call to record_disable_context,
# while calling the callback function in the meantime
try:
record_dpy.record_enable_context(ctx, record_callback)
except KeyboardInterrupt:
local_dpy.record_disable_context(ctx)
local_dpy.flush()
# Finally free the context
record_dpy.record_free_context(ctx)

11
vimrc
View file

@ -58,14 +58,14 @@ Plug 'junegunn/fzf.vim'
Plug 'ervandew/supertab'
Plug 'dpelle/vim-LanguageTool'
Plug 'terryma/vim-smooth-scroll'
" Plug 'vim-pandoc/vim-pandoc'
" Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
call plug#end()
""" COMPLETOR """
let g:deoplete#enable_at_startup = 0
let g:deoplete#enable_at_startup = 1
""" UNDOTREE """
@ -147,6 +147,7 @@ let g:languagetool_jar = "/usr/share/java/languagetool/languagetool-commandline.
""" vim-pandoc """
let g:pandoc#modules#disabled = ["folding"]
let g:pandoc#spell#enabled = 0
let g:pandoc#syntax#conceal#use = 0
@ -159,7 +160,7 @@ set number
set ruler
set wrap
set scrolloff=5
set scrolloff=10
set ignorecase
set smartcase
@ -184,6 +185,8 @@ set cursorcolumn
set splitbelow
set number relativenumber
syntax enable
" From http://stackoverflow.com/a/5004785/2766106