Merge pull request #2177 from r3claimer/next

Add volume reporting while in game
This commit is contained in:
r3claimer
2026-01-13 15:35:06 -08:00
committed by GitHub
3 changed files with 73 additions and 5 deletions

View File

@@ -9,6 +9,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <array>
#include <memory>
const std::string CONFIG_DIR = "/storage/.config/mako";
const std::string CONFIG_FILE = CONFIG_DIR + "/config";
@@ -50,6 +52,22 @@ void ensure_mako_config() {
}
}
// Check focused app function
std::string get_focused_app() {
std::string result;
std::array<char, 128> buffer;
std::unique_ptr<FILE, void(*)(FILE*)> pipe(
popen("swaymsg -t get_tree | jq -r '.. | select(.focused?) | .app_id'", "r"),
[](FILE* f){ if(f) pclose(f); }
);
if (!pipe) return "";
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
if (!result.empty() && result.back() == '\n') result.pop_back();
return result;
}
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <message>" << std::endl;
@@ -57,6 +75,30 @@ int main(int argc, char* argv[]) {
return 1;
}
// check for -no-es / -no-ra option
bool no_es_flag = false;
bool no_ra_flag = false;
for (int i = 2; i < argc; ++i) {
if (std::string(argv[i]) == "-no-es") {
no_es_flag = true;
}
if (std::string(argv[i]) == "-no-ra") {
no_ra_flag = true;
}
}
if (no_es_flag || no_ra_flag) {
std::string focused_app = get_focused_app();
// skip notification if -no-es and EmulationStation focused
if (no_es_flag && focused_app == "emulationstation") {
return 0;
}
// skip notification if -no-ra and Retorarch focused
if (no_ra_flag && focused_app == "com.libretro.RetroArch") {
return 0;
}
}
// Ensure the Mako config exists
ensure_mako_config();

View File

@@ -0,0 +1,22 @@
diff --git a/render.c b/render.c
index 8fed6d8..b157323 100644
--- a/render.c
+++ b/render.c
@@ -438,7 +438,7 @@ void render(struct mako_surface *surface, struct pool_buffer *buffer, int scale,
++visible_count;
}
}
-
+/*
if (hidden_count > 0) {
struct mako_notification *hidden_notif = create_notification(state);
hidden_notif->surface = surface;
@@ -478,7 +478,7 @@ void render(struct mako_surface *surface, struct pool_buffer *buffer, int scale,
}
destroy_notification(hidden_notif);
}
-
+*/
*rendered_width = max_width;
*rendered_height = total_height;
}

View File

@@ -138,13 +138,13 @@ FN_AB_ACTION_DOWN="$(get_setting key.function.ab.down)"
### Volume repeat function
start_volume_repeat() {
local direction=$1
# Stop any existing volume repeat
stop_volume_repeat
# Initial volume adjustment
volume ${direction}
# Start background process for repeating volume adjustments
(
sleep ${VOLUME_REPEAT_DELAY}
@@ -159,7 +159,7 @@ start_volume_repeat() {
fi
done
) &
VOLUME_REPEAT_PID=$!
${DEBUG} && log $0 "Started volume repeat (${direction}) with PID: ${VOLUME_REPEAT_PID}"
}
@@ -347,6 +347,8 @@ set +e
${DEBUG} && log $0 "Volume Up: Released"
VOLUME_UP_PRESSED=false
stop_volume_repeat
CUR_VOLUME=$(get_setting "audio.volume")
/usr/bin/mako-notify "Volume: ${CUR_VOLUME}%" -no-es
fi
;;
(${FUNCTION_VOLUME_DOWN_EVENT})
@@ -364,6 +366,8 @@ set +e
${DEBUG} && log $0 "Volume Down: Released"
VOLUME_DOWN_PRESSED=false
stop_volume_repeat
CUR_VOLUME=$(get_setting "audio.volume")
/usr/bin/mako-notify "Volume: ${CUR_VOLUME}%" -no-es
fi
;;
(${FUNCTION_POWER_PRESSED_EVENT})
@@ -451,7 +455,7 @@ set +e
if [ "${HOTKEY_A_PRESSED}" = true ]; then
${DEBUG} && log $0 "${FUNCTION_HOTKEY_BTN_EAST_EVENT}: Screenshot Taken"
/usr/bin/rocknix-screenshot
/usr/bin/mako-notify "Screenshot Saved"
/usr/bin/mako-notify "Screenshot Saved" -no-ra
fi
;;
(${FUNCTION_HOTKEY_BTN_WEST_EVENT})