Commit f189822b authored by nextime's avatar nextime

Configurable buttons/actions

parent f5af9770
......@@ -26,9 +26,131 @@ button_width = 20
button_height = 2
font_size = 12
[OBS:mdma]
host = 192.168.42.115
port = 4455
password = motorol4
# OUTPUT are shenes on OBS sending to a specific stream, can be a rtmp stream with
# OBS multistream plugin or a virtual cam, both the included in OBS or the ones
# from a plugin.
[OUTPUT:smleeloo]
obs = leeloo
scene = LIVE SFW
source_title = 5
source_closed = 4
source_tease = 3
[OUTPUT:smstefy]
obs = slut
scene = live SFW
source_title = 5
source_closed = 4
source_tease = 3
[OUTPUT:shine]
obs = slut
scene = SHINE
source_title = 4
source_closed = 2
source_tease = 3
#[OUTPUT:livejasmin]
#obs = slut
#scene = LIVE JM
#source_title = 4,5
#source_closed = 3
#source_tease = 2
# BUTTON:<rownum>:<button_name>
[BUTTON:1:private_shine]
title = Private Shine
action = private_shine
color = green
[BUTTON:1:private_stefy]
title = Private Stefy
action = private_stefy
color = green
[BUTTON:1:private_leelo]
title = Private Leeloo
action = private_leeloo
color = green
#[BUTTON:1:private_jasmine]
#title = Private Jasmine
#action = private_jasmine
#color = green
[BUTTON:2:shine_openclose]
title = Open/Close Shine
action = shine_openclose
color = orange
[BUTTON:2:stefy_openclose]
title = Open/Close Stefy
action = stefy_openclose
color = orange
[BUTTON:2:leelo_openclose]
title = Open/Close Leeloo
action = leelo_openclose
color = orange
#[BUTTON:2:leelo_livejasmine]
#title = Open/Close JASM
#action = jasmine_openclose
[BUTTON:3:tease_all]
title = Tease ALL
action = tease_all
color = blue
[BUTTON:3:tease]
title = Tease
action = tease
color = blue
[BUTTON:3:open_all]
title = Open ALL
action = open_all
color = blue
[ACTION:private_shine]
execute = /usr/local/bin/smblur_private
[ACTION:private_stefy]
execute = /usr/local/bin/smblur_private_stefy
[ACTION:private_leeloo]
execute = /usr/local/bin/smblur_private_leeloo
#[ACTION:private_jasmine]
#execute = /usr/local/bin/smblur_private_jasmin
[ACTION:leelo_openclose]
execute = /usr/local/bin/smblur_leelo
[ACTION:shine_openclose]
execute = /usr/local/bin/smblur_shine
[ACTION:stefy_openclose]
execute = /usr/local/bin/smblur_stefy
#[ACTION:jasmine_openclose]
#execute = /usr/local/bin/smblur_jasmin
[ACTION:tease_all]
execute = /usr/local/bin/smblur_tease
[ACTION:tease]
execute = /usr/local/bin/smblur_teaseall
[ACTION:open_all]
execute = /usr/local/bin/smblur_clean
# Copyright (C) 2023 Stefy Lanza <stefy@nexlab.net> and SexHack.me
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
def get_buttons():
r=1
buttons = {}
while r >= 1 and r<10:
buttons[r] = {}
for s in [x for x in config.sections() if 'BUTTON:'+str(r)+':' in x]:
values = config.items(s)
if len(values) > 0:
buttons[r][s.split(':',2)[2]] = {}
for t in values:
buttons[r][s.split(':',2)[2]][t[0]] = t[1]
r=r+1
if len(buttons[r-1].keys()) < 1:
del(buttons[r-1])
r=0
numrows = len(buttons.keys())
return buttons, numrows
......@@ -20,7 +20,7 @@ import webbrowser
import sys
import os
from utils import run_command
from guiutils import get_buttons
class VideoPlayer:
def __init__(self, master, video_url):
......@@ -58,6 +58,7 @@ class VideoPlayer:
# Play the video
self.player.play()
def create_panel_gui():
# Create the main window
window = tk.Tk()
......@@ -77,65 +78,47 @@ def create_panel_gui():
fright = tk.Frame(window)
fright.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True)
# Frame for the first two rows in the right frame
frame1 = tk.Frame(fright)
frame1.pack(fill=tk.BOTH, expand=True)
# Buttons configuration
buttons_row0 = [
('PRIVATE STEFY', 'smblur_private_stefy'),
('PRIVATE LEELOO', 'smblur_private_leeloo'),
('PRIVATE JASMIN', 'smblur_private_jasmin'),
('PRIVATE OTHER', 'smblur_private')
]
buttons_row1 = [
('OPEN/CLOSE STEFY', 'smblur_stefy'),
('OPEN/CLOSE LEELOO', 'smblur_leeloo'),
('OPEN/CLOSE JASMIN', 'smblur_jasmin'),
('OPEN/CLOSE OTHERS', 'smblur_shine')
]
# Create buttons for the first two rows
for j, (text, command) in enumerate(buttons_row0):
button = tk.Button(frame1, text=text, font=helv36, width=25, height=15, bg="green", fg="white",
command=lambda cmd=command: run_command(cmd))
button.grid(row=0, column=j, sticky='nsew')
for j, (text, command) in enumerate(buttons_row1):
button = tk.Button(frame1, text=text, font=helv36, width=25, height=15, bg="green", fg="white",
command=lambda cmd=command: run_command(cmd))
button.grid(row=1, column=j, sticky='nsew')
# Configure the columns in the first frame
for i in range(4):
frame1.grid_columnconfigure(i, weight=1)
# Frame for the third row in the right frame
frame2 = tk.Frame(fright)
frame2.pack(fill=tk.BOTH, expand=True)
# Row 2 with 3 buttons
buttons_row2 = [
('TEASE', 'smblur_tease'),
('TEASE ALL', 'smblur_teaseall'),
('OPEN', 'smblur_clean')
]
# Create buttons for the third row
for j, (text, command) in enumerate(buttons_row2):
button = tk.Button(frame2, text=text, font=helv36, width=30, height=25, bg="blue", fg="white",
command=lambda cmd=command: run_command(cmd))
button.grid(row=0, column=j, sticky='nsew')
# Configure the columns in the second frame
for i in range(3):
frame2.grid_columnconfigure(i, weight=1)
buttons, numrows = get_buttons()
print(numrows , buttons)
bh = int(55/numrows)
if numrows > 0:
row = 1
bframes = {}
while row <= numrows:
# create the frame for this row
bframes[row] = tk.Frame(fright)
bframes[row].pack(fill=tk.BOTH, expand=True)
# Calculate button width
bw=int(100/len(buttons[row].keys()))
# add the buttons
col=0
print(buttons[row])
for b in buttons[row].keys():
command=None
if config.has_section('ACTION:'+buttons[row][b]['action']):
command=config.get('ACTION:'+buttons[row][b]['action'], 'execute', fallback=None)
color=buttons[row][b]['color']
print(command)
button = tk.Button(bframes[row], text=buttons[row][b]['title'], font=helv36, width=bw, height=bh, bg=color, fg="white",
command=lambda cmd=command: run_command(cmd))
button.grid(row=0, column=col, sticky='nsew')
col = col+1
# Configure the columns in the frame
for i in range(len(buttons[row].keys())):
bframes[row].grid_columnconfigure(i, weight=1)
row=row+1
# Add a button to open web interface
web_button = tk.Button(frame2, text="Open Web Interface",
web_button = tk.Button(bframes[row-1], text="Open Web Interface",
command=lambda: webbrowser.open('http://localhost:5000'),
bg="purple", fg="white", font=helv36)
bg="purple", fg="white", font=helv36, height=2)
web_button.grid(row=1, column=1, sticky='nsew')
return window
......
......@@ -17,20 +17,48 @@ from flask import Flask, render_template, request
from utils import check_port_available, run_command, create_daemon
import sys
import os
from guiutils import get_buttons
# Flask App Setup
flask_app = Flask('SHMCamStudio', template_folder=TEMPLATE_DIR)
@flask_app.route('/')
def index():
return render_template('index.html', commands=COMMANDS)
buttons, numrows = get_buttons()
row = 1
style_rows=""
htmlbuttons=""
if numrows > 0:
while row <= numrows:
bspan = int(12/len(buttons[row].keys()))
style_rows=style_rows+"\n.button_row"+str(row)+" {\n grid-column: span "+str(bspan)+";\n}\n"
col=0
htmlbuttons=htmlbuttons+"<div class='button_row'>"
for b in buttons[row].keys():
command=buttons[row][b]['action']
color=buttons[row][b]['color']
htmlbuttons=htmlbuttons+"""<button style="color:white;background-color:"""+color+""";" class="button private button_row"""+str(row)+"""" onclick="executeCommand('"""+command+"""')">
"""+buttons[row][b]['title']+"""
</button>"""
htmlbuttons=htmlbuttons+"</div>"
row=row+1
return render_template('index.html', commands=COMMANDS, style_rows=style_rows, htmlbuttons=htmlbuttons)
@flask_app.route('/execute', methods=['POST'])
def execute():
command_key = request.form.get('command')
if command_key in COMMANDS:
result = run_command(COMMANDS[command_key])
if config.has_section('ACTION:'+command_key):
command = config.get('ACTION:'+command_key, 'execute', fallback=None)
if command:
result = run_command(command)
else:
return "No command available"
return result
else:
return "Invalid command", 400
......
......@@ -107,22 +107,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
transition: width 0.3s ease;
}
.sidebar.expanded ~ .buttons-container {
width: 66.66vw;
}
/* Button layout */
.buttons-container > .button {
grid-column: span 3;
.button_row {
display: grid;
grid-template-columns: repeat(12, 1fr);
width: 100%;
grid-column: span 12;
}
/* Third row layout */
.buttons-container > .button:nth-child(9),
.buttons-container > .button:nth-child(10),
.buttons-container > .button:nth-child(11) {
grid-column: span 4;
{{style_rows|safe}}
.sidebar.expanded ~ .buttons-container {
width: 66.66vw;
}
.button {
display: flex;
justify-content: center;
......@@ -181,45 +180,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
<!-- Buttons Container -->
<div class="buttons-container">
<!-- Private Commands - Row 1 -->
<button class="button private" onclick="executeCommand('private_stefy')">
PRIVATE STEFY
</button>
<button class="button private" onclick="executeCommand('private_leeloo')">
PRIVATE LEELOO
</button>
<button class="button private" onclick="executeCommand('private_jasmin')">
PRIVATE JASMIN
</button>
<button class="button private" onclick="executeCommand('private_other')">
PRIVATE OTHER
</button>
<!-- Toggle Commands - Row 2 -->
<button class="button toggle" onclick="executeCommand('toggle_stefy')">
OPEN/CLOSE STEFY
</button>
<button class="button toggle" onclick="executeCommand('toggle_leeloo')">
OPEN/CLOSE LEELOO
</button>
<button class="button toggle" onclick="executeCommand('toggle_jasmin')">
OPEN/CLOSE JASMIN
</button>
<button class="button toggle" onclick="executeCommand('toggle_others')">
OPEN/CLOSE OTHERS
</button>
<!-- Special Commands - Row 3 -->
<button class="button special" onclick="executeCommand('tease')">
TEASE
</button>
<button class="button special" onclick="executeCommand('tease_all')">
TEASE ALL
</button>
<button class="button special" onclick="executeCommand('open')">
OPEN
</button>
<div></div>
{{htmlbuttons|safe}}
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment