Skip to content

Commit

Permalink
Roughly finished
Browse files Browse the repository at this point in the history
  • Loading branch information
sierpinskiii committed Sep 9, 2022
1 parent de46dc6 commit e093664
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ dmypy.json

# Pyre type checker
.pyre/

id
9 changes: 9 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

sudo apt install xclip xsel
cp octaned.service.sample /etc/systemd/system/octaned.service
mkdir $HOME/.octane/
cp octane.py $HOME/.octane/
cp octane.sxhkdrc.sample %HOME/.octane/octane.sxhkdrc
chmod 644 /etc/systemd/system/octaned.service
systemctl enable octane.service
54 changes: 36 additions & 18 deletions octane.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
#!/usr/bin/python3
import requests, sys, time, subprocess
import requests, sys, subprocess
from datetime import datetime
from hashlib import blake2b

url = "http://127.0.0.1:3000/api/v1/"

roomid = sys.argv[3] if len(sys.argv) > 3 else "-1"
def newroom():
obj = {'name': 'string'}
x = requests.post(url, json=obj)
with open("id", "w") as f: # .octane.d/id
f.write(str(x.json()["id"]))
return x


try:
with open("id", "r") as f:
roomid = f.read()
except:
x = newroom()


if sys.argv[1] == "health":
x = requests.get(url + "health")

elif sys.argv[1] == "room":
url = url + "room/"
if sys.argv[2] == "new":
obj = {'name': 'string'}
x = requests.post(url, json=obj)
x = newroom()
elif sys.argv[2] == "delete":
url += roomid
x = requests.delete(url)
elif sys.argv[2] == "status":
url += roomid
x = requests.get(url)
elif sys.argv[2] == "switch":
elif sys.argv[2] == "connect":
url += roomid
obj = {"name": "string", "request": "connect"}
x = requests.post(url, json=obj)
elif sys.argv[2] == "disconnect":
url += roomid
obj = {"name": "string", "request": "string"}
obj = {"name": "string", "request": "disconnect"}
x = requests.post(url, json=obj)

elif sys.argv[1] == "content":
Expand All @@ -31,7 +48,8 @@
elif sys.argv[2] == "get":
x = requests.get(url)
elif sys.argv[2] == "put":
data = subprocess.run(['xclip', '-o', '-selection'], stdout=subprocess.PIPE).stdout.decode('utf-8')
data = "mockup"
# data = subprocess.run(['xclip', '-o', '-selection'], stdout=subprocess.PIPE).stdout.decode('utf-8')
x = requests.put(url, data=data)

elif sys.argv[1] == "status":
Expand All @@ -41,17 +59,17 @@
elif sys.argv[2] == "get":
x = requests.get(url)
elif sys.argv[2] == "put":
obj = f'''{
"device": {subprocess.run(['uname', '-r'],
stdout=subprocess.PIPE).stdout.decode('utf-8')},
"hash": "string",
"mime": "string",
"name": "string",
"timestamp": {time.time()},
"type": "string"
}'''
data = b"mockup"
# data = subprocess.run(['xclip', '-o', '-selection'], stdout=subprocess.PIPE).stdout.decode('utf-8')
hashval = blake2b(data).hexdigest()
print(hashval)
obj = {"device": "string",
"hash": hashval,
"mime": "string",
"name": "string",
"timestamp": 0,
"type": "string"}
x = requests.put(url, json=obj)



print(x.text)
7 changes: 5 additions & 2 deletions octane.sxhkdrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
win + c
octaine status put
$HOME/.octane/octane.py room connect
$HOME/.octane/octane.py status put
$HOME/.octane/octane.py content put
$HOME/.octane/octane.py room disconnect

win + v
octaine status get | xdotool type
$HOME/.octane/octane.py status get | xdotool type
12 changes: 12 additions & 0 deletions octaned.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Quantilier Startup Service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
WorkingDirectory=$HOME/.octane/
ExecStart=/usr/bin/sxhkd -c $HOME/.octane/octane.sxhkdrc

[Install]
WantedBy=multi-user.target

0 comments on commit e093664

Please sign in to comment.