Before I screw things up

This commit is contained in:
Geoffrey Frogeye 2019-11-09 15:28:16 +01:00
parent 45058b4272
commit 8ec06d3618
4 changed files with 71 additions and 4 deletions

View file

@ -398,6 +398,7 @@ exec --no-startup-id keynav # Keyboard cursor controller
# exec --no-startup-id ~/.config/i3/ashuffle # MPD Auto-refill # exec --no-startup-id ~/.config/i3/ashuffle # MPD Auto-refill
exec --no-startup-id autorandr --change # Screen configuration and everything that depends on it exec --no-startup-id autorandr --change # Screen configuration and everything that depends on it
exec --no-startup-id ~/.config/i3/batteryNotify -d # Battery state notification exec --no-startup-id ~/.config/i3/batteryNotify -d # Battery state notification
exec --no-startup-id ~/.config/i3/screentime # Activity tracker
set $ignore #ff00000 set $ignore #ff00000

66
config/i3/screentime Executable file
View file

@ -0,0 +1,66 @@
#!/usr/bin/env python3
"""
Logs what window is in focus
"""
import csv
import datetime
import os
import typing
import i3ipc
class ScreenTime:
FIELDS = ["date", "type", "class", "role", "instance", "title"]
def write(self, line: typing.Dict) -> None:
now = datetime.datetime.now()
line["date"] = now.timestamp()
print("WROTE", line)
with open(self.csv_path, 'a') as typedfd:
writer = csv.DictWriter(typedfd, fieldnames=self.FIELDS)
writer.writerow(line)
def on_window_event(self, _: i3ipc.connection.Connection,
e: i3ipc.events.WindowEvent) -> None:
focused = self.i3.get_tree().find_focused()
self.write({
"type": "window_" + e.change,
"class": focused.window_class,
"role": focused.window_role,
"title": focused.window_title,
"instance": focused.window_instance,
})
def on_mode_event(self, _: i3ipc.connection.Connection,
e: i3ipc.events.ModeEvent) -> None:
self.write({
"type": "mode",
"title": e.change
})
def __init__(self) -> None:
self.i3 = i3ipc.Connection()
self.i3.on(i3ipc.Event.WINDOW, self.on_window_event)
self.i3.on(i3ipc.Event.MODE, self.on_mode_event)
self.csv_path = os.path.join(
os.path.expanduser(
os.getenv('XDG_CACHE_PATH', '~/.cache/')),
'screentime.csv')
if not os.path.isfile(self.csv_path):
with open(self.csv_path, 'w') as typedfd:
writer = csv.DictWriter(typedfd, fieldnames=self.FIELDS)
writer.writeheader()
self.write({"type": "start"})
def main(self) -> None:
self.i3.main()
if __name__ == '__main__':
ST = ScreenTime()
ST.main()

View file

@ -266,7 +266,7 @@ input {
# #
audio_output { audio_output {
type "httpd" type "httpd"
name "Musique de Geoffrey" name "geoffrey-music-httpd"
encoder "vorbis" # optional, vorbis or lame encoder "vorbis" # optional, vorbis or lame
port "8600" port "8600"
bind_to_address "0.0.0.0" # optional, IPv4 or IPv6 bind_to_address "0.0.0.0" # optional, IPv4 or IPv6
@ -280,7 +280,7 @@ audio_output {
# #
audio_output { audio_output {
type "pulse" type "pulse"
name "Musiques de Geoffrey" name "geoffrey-music-pulse"
## server "remote_server" # optional ## server "remote_server" # optional
## sink "remote_server_sink" # optional ## sink "remote_server_sink" # optional
} }

View file

@ -83,8 +83,8 @@ direnv XDG_CONFIG_HOME "$HOME/.config"
export XDG_DATA_DIRS="/usr/local/share/:/usr/share/" export XDG_DATA_DIRS="/usr/local/share/:/usr/share/"
export XDG_CONFIG_DIRS="/etc/xdg" export XDG_CONFIG_DIRS="/etc/xdg"
direnv XDG_CACHE_HOME "$HOME/.cache" direnv XDG_CACHE_HOME "$HOME/.cache"
direnv XDG_RUNTIME_DIR "$HOME/.local/run" # Please don't set XDG_RUNTIME_DIR as it
chmod 0700 "$XDG_RUNTIME_DIR" # screw with user daemons such as PulseAudio
# Path # Path