Last active
November 18, 2021 03:59
-
-
Save moyashi/1408aa4979362a0d4b9bb0129b9a1f26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
import subprocess | |
from subprocess import PIPE | |
array = {"ANYCUBIC MEGA-S":"192.168.1.10", | |
"ANYCUBIC i3 MEGA":"192.168.1.20", | |
"KINGROON KP3S-1":"192.168.1.30", | |
"KINGROON KP3S-2":"192.168.1.40", | |
"KINGROON KP3S-3":"192.168.1.50", | |
"HyperCube BLV Fusion":"192.168.1.60", | |
"Prusa i3 MK3S":"192.168.1.70"} | |
input_text = '\n'.join(array.keys()) | |
proc = subprocess.run("/usr/local/bin/choose", shell=True, input=input_text, stdout=PIPE, stderr=PIPE, text=True) | |
if (proc.stdout != ""): | |
cmd = "open http://" + array[proc.stdout] | |
subprocess.run(cmd, shell=True, input=input_text, stdout=PIPE, stderr=PIPE, text=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
プリンターの台数が増えてOctoPrintを開くのが困難になってきたのでセレクターを介して起動できるようにした。
使っているセレクターはmacOS用のchooseというもの。
カーソルキーで候補から選べるほか、インクリメンタルサーチも可能。
https://github.com/chipsenkbeil/choose
インストールはbrew install choose-gui
自分はBetter Touch Toolから「シェルスクリプト/タスクの実行」をキーボードショートカットに割り当てて実行している。
パスが通っていなくてもいいように、コマンドはフルパスで。
/usr/local/bin/python3 /Users/stallman/Desktop/printer_select.py