There's now a bezos_ctl and bezos_cli that can control the presentation window. The bezos_ctl is compile as a windows app so that it won't flash a cmd.exe window when run from launchers like Stream Deck. The bezos_cli is compiled as a console app so you can use it from the command line.
parent
717f90eae4
commit
26ed4b74ce
@ -0,0 +1,71 @@ |
||||
#include <fmt/xchar.h> |
||||
#include "dbc.hpp" |
||||
#include <SFML/Network/UdpSocket.hpp> |
||||
#include <memory> |
||||
#include <unistd.h> |
||||
|
||||
using namespace std::chrono_literals; |
||||
|
||||
const int DEFAULT_PORT=9898; |
||||
|
||||
struct Options { |
||||
bool help{false}; |
||||
bool focus{false}; |
||||
bool error{false}; |
||||
unsigned short port=DEFAULT_PORT; |
||||
}; |
||||
|
||||
void request_focus(Options& options) { |
||||
fmt::println("Moving control window front: port={}", options.port); |
||||
sf::UdpSocket sock; |
||||
uint32_t cmd = 2; |
||||
auto localhost = sf::IpAddress::getLocalAddress(); |
||||
auto result = sock.send(&cmd, sizeof cmd, *localhost, options.port); |
||||
} |
||||
|
||||
void print_usage() { |
||||
fmt::println("USAGE: bezos [-p {}] [-hf] -d deck.md", DEFAULT_PORT); |
||||
} |
||||
|
||||
Options parse_options(int argc, char* argv[]) { |
||||
int opt = 0; |
||||
Options result; |
||||
|
||||
while((opt = getopt(argc, argv, "fhp:")) != -1) { |
||||
switch(opt) { |
||||
case 'f': |
||||
result.focus=true; |
||||
break; |
||||
case 'h': |
||||
print_usage(); |
||||
return {.help=true}; |
||||
break; |
||||
case 'p': |
||||
result.port = std::stoi(optarg); |
||||
break; |
||||
default: |
||||
print_usage(); |
||||
return {.error=true}; |
||||
} |
||||
} |
||||
|
||||
if(!result.focus) { |
||||
print_usage(); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
|
||||
int main(int argc, char *argv[]) { |
||||
auto options = parse_options(argc, argv); |
||||
|
||||
if(options.focus) { |
||||
request_focus(options); |
||||
return 0; |
||||
} else if(options.help) { |
||||
return 0; |
||||
} else if(options.error) { |
||||
return 1; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue