Move i3 config to home module folder

This commit is contained in:
2024-02-01 13:28:29 +01:00
parent 0cf00f5fbf
commit 607ac75200
18 changed files with 4 additions and 5 deletions

View File

@@ -0,0 +1,11 @@
#!/bin/sh
xrandr | grep -q "HDMI-1 connected"
if [ "$?" -eq "0" ]; then
echo "Two screens available"
~/.screenlayout/twoscreens.sh
else
echo "Only one screen available"
~/.screenlayout/onescreen.sh
fi

View File

@@ -0,0 +1,21 @@
#!/bin/sh
xrandr | grep -q "HDMI-1 connected"
if [ "$?" -eq "0" ]; then
echo "Two screens available"
MIRROR_FILE=~/.screenlayout/mirror-primary
if [ -e "$MIRROR_FILE" ]; then
echo "Mode set to mirror"
rm "$MIRROR_FILE"
~/.screenlayout/twoscreens-mirror.sh
else
echo "Mode set to left-right"
touch "$MIRROR_FILE"
~/.screenlayout/twoscreens.sh
fi
else
echo "Only one screen available"
~/.screenlayout/onescreen.sh
fi

View File

@@ -0,0 +1,78 @@
#!/bin/python3
import subprocess
import time
import psutil
NOTEBOOK_DIR = "~/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():
print("No notebook instance running. Starting it...")
subprocess.Popen(f"jupyter notebook --notebook-dir={NOTEBOOK_DIR} --port={PORT} --no-browser", shell=True)
else:
print("Notebook instance already running.")
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)
# url = f"http://localhost:{PORT}/notebooks/calculator.ipynb?token={token}"
url = f"http://localhost:{PORT}/?token={token}"
subprocess.call(f"$BROWSER '{url}'", shell=True)
finally:
# TODO: not reliably working
if not isOtherProcessRunning():
try:
subprocess.run(f"jupyter notebook stop {PORT}", shell=True)
except Exception:
pass

View File

@@ -0,0 +1,3 @@
#!/bin/sh
matlab -desktop -sd ~/dev/bachelor-thesis/simulation

View File

@@ -0,0 +1,40 @@
#!/bin/sh
start_if_not_running()
{
program=$1
pidof -sq $program
if [ "$?" -eq "1" ]; then
start_program $1
else
echo "$program is already running"
fi
}
start_program()
{
program=$1
echo "Starting $program..."
$program & > /dev/null
}
i3-msg 'workspace 9; append_layout ~/.config/i3/workspace-chat-schildi-tele-rocket.json'
{{#if dotter.packages.nix}}
start_program schildichat-desktop
sleep 0.1
start_program telegram-desktop
sleep 0.1
start_program rocketchat-desktop
sleep 0.1
start_program thunderbird
sleep 0.1
{{else}}
start_program chat.schildi.desktop
sleep 0.1
start_program telegram-desktop
sleep 0.1
start_program chat.rocket.RocketChat
sleep 0.1
start_program thunderbird
sleep 0.1
{{/if}}

View File

@@ -0,0 +1,20 @@
#!/bin/sh
HDMI_SINK="alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink"
LAPTOP_SINK="alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink"
HDMI_ICON=$(pactl info | grep -q $HDMI_SINK && echo "checkbox")
LAPTOP_ICON=$(pactl info | grep -q $LAPTOP_SINK && echo "checkbox")
HDMI_VOLUME=$(pactl get-sink-volume $HDMI_SINK | head -n 1 | awk '{print $5}')
LAPTOP_VOLUME=$(pactl get-sink-volume $LAPTOP_SINK | head -n 1 | awk '{print $5}')
read -r -d '' CONF <<EOF
Open Pavucontrol,pavucontrol,pavucontrol
^sep()
HDMI - $HDMI_VOLUME,pactl set-default-sink $HDMI_SINK,$HDMI_ICON
Laptop - $LAPTOP_VOLUME,pactl set-default-sink $LAPTOP_SINK,$LAPTOP_ICON
EOF
echo "$CONF" | jgmenu --simple

View File

@@ -0,0 +1,4 @@
#!/bin/bash
LC_NUMERIC=en_US.utf8
rofi -show calc -modi calc -no-show-match -no-sort -terse -calc-command "echo -n '{result}' | xclip"

View File

@@ -0,0 +1,6 @@
#!/bin/bash
zoom &
#i3-msg "workspace --no-auto-back-and-forth 5; exec mousepad ~/Nextcloud/studium/zoom.txt"
i3-msg "workspace --no-auto-back-and-forth 5; append_layout ~/.config/i3/workspace-zoom.json"