Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "subprojects/qrcodegen"]
path = subprojects/qrcodegen
url = https://github.com/nayuki/QR-Code-generator
[submodule "subprojects/libuiohook"]
path = subprojects/libuiohook
url = https://github.com/kwhat/libuiohook
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ option(USE_KEYCHAIN "Store the token in the keychain (default)" ON)
option(ENABLE_NOTIFICATION_SOUNDS "Enable notification sounds (default)" ON)
option(ENABLE_RNNOISE "Enable RNNoise for voice activity detection (default)" ON)
option(ENABLE_QRCODE_LOGIN "Enable QR code login (default)" ON)
option(ENABLE_GLOBAL_HOTKEY "Enable global hotkeys for mute and deafen (default)" ON)

find_package(nlohmann_json REQUIRED)
find_package(CURL)
Expand Down Expand Up @@ -113,6 +114,19 @@ endif ()
find_package(spdlog REQUIRED)
target_link_libraries(abaddon spdlog::spdlog)

if (ENABLE_GLOBAL_HOTKEY)
target_compile_definitions(abaddon PRIVATE WITH_HOTKEYS)

find_package(uiohook QUIET)
if (NOT uiohook_FOUND)
message("uiohook was not found and will be included as a submodule")
add_subdirectory(subprojects/libuiohook)
target_link_libraries(abaddon uiohook)
else ()
target_link_libraries(abaddon uiohook)
endif ()
endif ()

target_link_libraries(abaddon ${SQLite3_LIBRARIES})
target_link_libraries(abaddon ${GTKMM_LIBRARIES})
target_link_libraries(abaddon ${ZLIB_LIBRARY})
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Current features:
* Emojis<sup>2</sup>
* Thread support<sup>3</sup>
* Animated avatars, server icons, emojis (can be turned off)
* Global hotkeys support

1 - Abaddon tries its best (though is not perfect) to make Discord think it's a legitimate web client. Some of the
things done to do this
Expand Down Expand Up @@ -173,6 +174,7 @@ spam filter's wrath:
* [libopus](https://opus-codec.org/) (optional, required for voice)
* [libsodium](https://doc.libsodium.org/) (optional, required for voice)
* [rnnoise](https://gitlab.xiph.org/xiph/rnnoise) (optional, provided as submodule, noise suppression and improved VAD)
* [libuiohook](https://github.com/kwhat/libuiohook) (optional, provided as submodule, global hotkeys)

### TODO:

Expand Down Expand Up @@ -352,6 +354,13 @@ For example, memory_db would be set by adding `memory_db = true` under the line
| `vad` | string | rnnoise if enabled, gate otherwise | Method used for voice activity detection. Changeable in UI |
| `backends` | string | empty | Change backend priority when initializing miniaudio: `wasapi;dsound;winmm;coreaudio;sndio;audio4;oss;pulseaudio;alsa;jack` |

#### hotkeys

| Setting | Type | Default | Description |
|----------|--------|-----------|-------------------------------------------|
| `mute` | string | \<Alt\>M | Shortcut to mute microphone in voice call |
| `deafen` | string | \<Alt\>D | Shortcut to deafen audio in voice call |

#### windows

| Setting | Type | Default | Description |
Expand Down
46 changes: 46 additions & 0 deletions cmake/Finduiohook.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function(add_imported_library library headers)
add_library(uiohook::uiohook UNKNOWN IMPORTED)
set_target_properties(uiohook::uiohook PROPERTIES
IMPORTED_LOCATION "${library}"
INTERFACE_INCLUDE_DIRECTORIES "${headers}"
)

set(uiohook_FOUND 1 CACHE INTERNAL "uiohook found" FORCE)
set(uiohook_LIBRARIES "${library}" CACHE STRING "Path to uiohook library" FORCE)
set(uiohook_INCLUDES "${headers}" CACHE STRING "Path to uiohook headers" FORCE)
mark_as_advanced(FORCE uiohook_LIBRARIES)
mark_as_advanced(FORCE uiohook_INCLUDES)
endfunction()

if(uiohook_LIBRARIES AND uiohook_INCLUDES)
add_imported_library(${uiohook_LIBRARIES} ${uiohook_INCLUDES})
return()
endif()

set(_uiohook_DIR "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/libuiohook")

find_library(uiohook_LIBRARY_PATH
NAMES libuiohook uiohook
PATHS
"${_uiohook_DIR}/lib"
/usr/lib
)

find_path(uiohook_HEADER_PATH
NAMES uiohook.h
PATHS
"${_uiohook_DIR}/include"
/usr/include
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
uiohook DEFAULT_MSG uiohook_LIBRARY_PATH uiohook_HEADER_PATH
)

if(uiohook_FOUND)
add_imported_library(
"${uiohook_LIBRARY_PATH}"
"${uiohook_HEADER_PATH}"
)
endif()
50 changes: 50 additions & 0 deletions src/abaddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Abaddon::Abaddon()
#ifdef WITH_VOICE
, m_audio(GetSettings().Backends)
#endif
#ifdef WITH_HOTKEYS
, m_HotkeyManager()
#endif
{
LoadFromSettings();

Expand Down Expand Up @@ -489,6 +492,36 @@ void Abaddon::DiscordOnThreadUpdate(const ThreadUpdateData &data) {
void Abaddon::OnVoiceConnected() {
m_audio.StartCaptureDevice();
ShowVoiceWindow();

#ifdef WITH_HOTKEYS
m_mute_hotkey_id = m_HotkeyManager.registerHotkey(GetSettings().ToggleMute.c_str(), [this]() {
if (m_voice_window != nullptr) {
auto voice_window = dynamic_cast<VoiceWindow*>(m_voice_window);
if (voice_window) {
m_is_mute = !voice_window->GetMute();
voice_window->SetMute( m_is_mute );
return;
}
}
m_is_mute = !m_is_mute;
m_discord.SetVoiceMuted( m_is_mute );
m_audio.SetCapture(!m_is_mute);
});

m_deafen_hotkey_id = m_HotkeyManager.registerHotkey(GetSettings().ToggleDeafen.c_str(), [this]() {
if (m_voice_window != nullptr) {
auto voice_window = dynamic_cast<VoiceWindow*>(m_voice_window);
if (voice_window) {
m_is_deaf = !voice_window->GetDeaf();
voice_window->SetDeaf( m_is_deaf );
return;
}
}
m_is_deaf = !m_is_deaf;
m_discord.SetVoiceDeafened( m_is_deaf );
m_audio.SetPlayback(!m_is_deaf);
});
#endif
}

void Abaddon::OnVoiceDisconnected() {
Expand All @@ -497,6 +530,11 @@ void Abaddon::OnVoiceDisconnected() {
if (m_voice_window != nullptr) {
m_voice_window->close();
}

#ifdef WITH_HOTKEYS
HotkeyManager().unregisterHotkey(m_mute_hotkey_id);
HotkeyManager().unregisterHotkey(m_deafen_hotkey_id);
#endif
}

void Abaddon::ShowVoiceWindow() {
Expand All @@ -506,11 +544,17 @@ void Abaddon::ShowVoiceWindow() {
m_voice_window = wnd;

wnd->signal_mute().connect([this](bool is_mute) {
#ifdef WITH_HOTKEYS
m_is_mute = is_mute;
#endif
m_discord.SetVoiceMuted(is_mute);
m_audio.SetCapture(!is_mute);
});

wnd->signal_deafen().connect([this](bool is_deaf) {
#ifdef WITH_HOTKEYS
m_is_deaf = is_deaf;
#endif
m_discord.SetVoiceDeafened(is_deaf);
m_audio.SetPlayback(!is_deaf);
});
Expand Down Expand Up @@ -1135,6 +1179,12 @@ AudioManager &Abaddon::GetAudio() {
}
#endif

#ifdef WITH_HOTKEYS
GlobalHotkeyManager& Abaddon::HotkeyManager() {
return Get().m_HotkeyManager;
}
#endif

void Abaddon::on_tray_click() {
m_main_window->set_visible(!m_main_window->is_visible());
}
Expand Down
18 changes: 18 additions & 0 deletions src/abaddon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include "notifications/notifications.hpp"
#include "audio/manager.hpp"

#ifdef WITH_HOTKEYS
#include "misc/GlobalHotkeyManager.hpp"
#endif

#define APP_TITLE "Abaddon"

class AudioManager;
Expand Down Expand Up @@ -101,6 +105,10 @@ class Abaddon {
void ShowVoiceWindow();
#endif

#ifdef WITH_HOTKEYS
static GlobalHotkeyManager& HotkeyManager();
#endif

SettingsManager::Settings &GetSettings();

Glib::RefPtr<Gtk::CssProvider> GetStyleProvider();
Expand Down Expand Up @@ -177,6 +185,16 @@ class Abaddon {
#ifdef WITH_VOICE
AudioManager m_audio;
Gtk::Window *m_voice_window = nullptr;
#ifdef WITH_HOTKEYS
int m_mute_hotkey_id;
int m_deafen_hotkey_id;
bool m_is_mute = false;
bool m_is_deaf = false;
#endif
#endif

#ifdef WITH_HOTKEYS
GlobalHotkeyManager m_HotkeyManager;
#endif

mutable std::mutex m_mutex;
Expand Down
Loading