2023-01-13 15:13:56 +00:00
|
|
|
#include "Window.h"
|
|
|
|
#include "Common.h"
|
|
|
|
#include "System.h"
|
|
|
|
#include "Bar.h"
|
|
|
|
#include "AudioFlyin.h"
|
2023-01-14 22:18:34 +00:00
|
|
|
#include "BluetoothDevices.h"
|
2023-01-28 14:07:07 +00:00
|
|
|
#include "Plugin.h"
|
2023-01-30 15:57:15 +00:00
|
|
|
#include "Config.h"
|
2023-01-13 15:13:56 +00:00
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
const char* audioTmpFileOpen = "/tmp/gBar__audio";
|
|
|
|
|
2023-02-22 15:45:29 +00:00
|
|
|
static bool flyin = false;
|
|
|
|
void OpenAudioFlyin(Window& window, int32_t monitor, AudioFlyin::Type type)
|
|
|
|
{
|
|
|
|
flyin = true;
|
|
|
|
if (access(audioTmpFileOpen, F_OK) != 0)
|
|
|
|
{
|
|
|
|
FILE* audioTempFile = fopen(audioTmpFileOpen, "w");
|
|
|
|
AudioFlyin::Create(window, monitor, type);
|
|
|
|
fclose(audioTempFile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Already open, close
|
|
|
|
LOG("Audio flyin already open");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 15:13:56 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
System::Init();
|
|
|
|
|
|
|
|
int32_t monitor = -1;
|
|
|
|
if (argc >= 3)
|
|
|
|
{
|
|
|
|
monitor = atoi(argv[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Window window;
|
|
|
|
ASSERT(argc >= 2, "Too little arguments!");
|
|
|
|
if (strcmp(argv[1], "bar") == 0)
|
|
|
|
{
|
|
|
|
Bar::Create(window, monitor);
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[1], "audio") == 0)
|
|
|
|
{
|
2023-02-22 15:45:29 +00:00
|
|
|
OpenAudioFlyin(window, monitor, AudioFlyin::Type::Speaker);
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[1], "mic") == 0)
|
|
|
|
{
|
|
|
|
OpenAudioFlyin(window, monitor, AudioFlyin::Type::Microphone);
|
2023-01-13 15:13:56 +00:00
|
|
|
}
|
2023-01-30 15:57:15 +00:00
|
|
|
#ifdef WITH_BLUEZ
|
2023-01-14 22:18:34 +00:00
|
|
|
else if (strcmp(argv[1], "bluetooth") == 0)
|
|
|
|
{
|
2023-01-30 15:57:15 +00:00
|
|
|
if (RuntimeConfig::Get().hasBlueZ)
|
|
|
|
{
|
|
|
|
BluetoothDevices::Create(window, monitor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LOG("Blutooth disabled, cannot open bluetooth widget!");
|
|
|
|
exit(1);
|
|
|
|
}
|
2023-01-14 22:18:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
2023-01-28 14:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Plugin::LoadWidgetFromPlugin(argv[1], window, monitor);
|
|
|
|
}
|
2023-01-13 15:13:56 +00:00
|
|
|
|
|
|
|
window.Run(argc, argv);
|
|
|
|
|
|
|
|
System::FreeResources();
|
2023-02-22 15:45:29 +00:00
|
|
|
if (flyin)
|
2023-01-13 15:13:56 +00:00
|
|
|
{
|
|
|
|
remove(audioTmpFileOpen);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|