diff --git a/i3/config b/i3/config index 4e1cb8c..8c97d63 100644 --- a/i3/config +++ b/i3/config @@ -241,7 +241,7 @@ bindsym $mod+Print mode "$mode_screenshot" bindsym $mod+Ctrl+Right move workspace to output right bindsym $mod+Ctrl+Left move workspace to output right -bindsym $mod+c exec xfce4-terminal -e qalc +bindsym $mod+c exec jupyter-calculator bindsym $mod+p exec xwacomcalibrate workspace_auto_back_and_forth yes @@ -277,8 +277,8 @@ exec --no-startup-id "i3-msg 'workspace 9: Chat; append_layout ~/.config/i3/work exec firefox exec thunderbird -exec chat.rocket.RocketChat no_focus -exec element-desktop no_focus +#exec chat.rocket.RocketChat no_focus +exec im.riot.Riot no_focus exec telegram-desktop no_focus exec --no-startup-id nm-applet diff --git a/i3/jupyter-calculator b/i3/jupyter-calculator new file mode 100755 index 0000000..49707d0 --- /dev/null +++ b/i3/jupyter-calculator @@ -0,0 +1,71 @@ +#!/bin/python3 + +import subprocess +import time +import psutil + +NOTEBOOK_DIR = "/home/julian/jupyter-notebooks/" +PORT = "8988" + +def isOtherProcessRunning(): + process_count = 0 + for proc in psutil.process_iter(): + try: + pinfo = proc.as_dict(attrs=['pid', 'name', 'create_time']) + if "jupyter-calc" in pinfo['name'].lower(): + process_count += 1 + except (psutil.NoSuchProcess, psutil.AccessDenied , psutil.ZombieProcess) : + pass + return process_count > 1 + +def getNotebookPort(line): + url = line.split(" :: ")[0] + return url.split("localhost:")[1].split("/")[0] + +def getNotebookToken(line): + url = line.split(" :: ")[0] + return url.split("token=")[1] + + +def isNotebookRunning(): + answer = subprocess.check_output("jupyter notebook list", shell=True) + lines = answer.decode("utf-8").split("\n") + if lines[0] != "Currently running servers:": + raise Exception("Invalid jupyter status message") + + for i in range(1, len(lines) -1): + if getNotebookPort(lines[i]) == PORT: + return getNotebookToken(lines[i]) + return None + +if __name__ == "__main__": + try: + if not isNotebookRunning(): + subprocess.Popen(f"jupyter notebook --notebook-dir={NOTEBOOK_DIR} --port={PORT} --no-browser", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + max_wait_seconds = 3 + delta_t_seconds = 0.1 + + current_wait_seconds = 0 + + token = "" + while True: + token = isNotebookRunning() + if token: + break + + time.sleep(delta_t_seconds) + current_wait_seconds += delta_t_seconds + if current_wait_seconds >= max_wait_seconds: + raise Exception(f"Maximum wait time of {max_wait_seconds} exceeded!") + + subprocess.call(f"cp {NOTEBOOK_DIR}calculator_template.ipynb {NOTEBOOK_DIR}calculator.ipynb", shell=True, stdout=None) + subprocess.call(f"electron 'http://localhost:{PORT}/notebooks/calculator.ipynb?token={token}'", shell=True, stdout=None) + + finally: + # TODO: not reliably working + if not isOtherProcessRunning(): + try: + subprocess.run(f"jupyter notebook stop {PORT}", shell=True) + except Exception: + pass diff --git a/i3/setupZoom b/i3/setupZoom index 999bbc5..a41a0a4 100755 --- a/i3/setupZoom +++ b/i3/setupZoom @@ -2,5 +2,5 @@ zoom & -i3-msg "workspace --no-auto-back-and-forth 5; exec mousepad /home/julian/jhome/nextcloud/studium/zoom.txt" +i3-msg "workspace --no-auto-back-and-forth 5; exec mousepad /home/julian/Nextcloud/studium/zoom.txt" i3-msg "workspace --no-auto-back-and-forth 5; append_layout ~/.config/i3/workspace-zoom.json" diff --git a/i3/workspace-chat.json b/i3/workspace-chat.json index ad001fc..4b2e01d 100644 --- a/i3/workspace-chat.json +++ b/i3/workspace-chat.json @@ -1,10 +1,11 @@ // vim:ts=4:sw=4:et { - // tabbed split container with 3 children + // splith split container with 2 children "border": "normal", "floating": "auto_off", - "layout": "tabbed", - "percent": null, + "layout": "splith", + "marks": [], + "percent": 1, "type": "con", "nodes": [ { @@ -17,12 +18,14 @@ "x": 1680, "y": 24 }, + "marks": [], "name": "Telegram", - "percent": 0.333333333333333, + "percent": 0.5, "swallows": [ { "class": "^TelegramDesktop$", "instance": "^telegram\\-desktop$" + // "title": "^Telegram\\ \\(18\\)$" } ], "type": "con" @@ -37,37 +40,19 @@ "x": 2242, "y": 46 }, + "marks": [], "name": "Element", - "percent": 0.333333333333333, + "percent": 0.5, "swallows": [ { "class": "^Element$", "instance": "^element$" - } - ], - "type": "con" - }, - { - "border": "normal", - "current_border_width": 2, - "floating": "auto_off", - "geometry": { - "height": 1002, - "width": 556, - "x": 2802, - "y": 46 - }, - "name": "Rocket Chat", - "percent": 0.333333333333333, - "swallows": [ - { - "class": "^Rocket\\.Chat$", - "instance": "^rocket\\.chat$" + // "title": "^Element\\ \\|\\ wmutter$", + // "window_role": "^browser\\-window$" } ], "type": "con" } - ] } diff --git a/i3blocks/activity b/i3blocks/activity new file mode 100755 index 0000000..8809676 --- /dev/null +++ b/i3blocks/activity @@ -0,0 +1,30 @@ +#!/bin/sh + +NONE="None" + +get_current_activity() { + activity=$(hamster current) + if [ "$activity" = "No activity" ]; then + echo $NONE + else + IFS=' ' + read -ra ADDR <<< "$activity" + echo "${ADDR[2]}" + fi +} + + +case "$BLOCK_BUTTON" in + 1|2|3) + current_activity=$(get_current_activity) + if [ "$current_activity" = "$NONE" ]; then + hamster start "Comu@Work#Flexibill App" + else + hamster stop + fi +esac + +current_activity=$(get_current_activity) + +echo "$LABEL $current_activity" +echo "$LABEL $current_activity" diff --git a/i3blocks/config b/i3blocks/config index 5400b38..031b245 100644 --- a/i3blocks/config +++ b/i3blocks/config @@ -10,6 +10,11 @@ separator=true separator_block_width=15 +[activity] +command=./activity +interval=10 +LABEL= + [volume] command=./volume LABEL= @@ -24,4 +29,4 @@ LABEL= [calendar] command=./calendar interval=1 -LABEL= \ No newline at end of file +