Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something seems to have changed with regard to dbus? #1684

Open
tv21 opened this issue Jan 17, 2025 · 0 comments
Open

Something seems to have changed with regard to dbus? #1684

tv21 opened this issue Jan 17, 2025 · 0 comments

Comments

@tv21
Copy link

tv21 commented Jan 17, 2025

For several months I have been running a bash script (under Ubuntu 24.04) that looks like this:

#!/bin/bash

# Define the lock file
LOCKFILE="/tmp/$(basename "$0").lock"

# Use flock to acquire the lock
exec 200>"$LOCKFILE"
if ! flock -n 200; then
  # echo "Another instance of $(basename "$0") is already running. Exiting."
  exit 1
fi

# Ensure the lock file is removed on exit
trap 'flock -u 200' EXIT

# Function to check if the system has been rebooted within the last 2 minutes
has_recent_reboot() {
  local uptime_seconds
  uptime_seconds=$(awk '{print $1}' /proc/uptime | cut -d. -f1)
  if [ "$uptime_seconds" -le 120 ]; then
    return 0  # True: system has been rebooted within the last 2 minutes
  else
    return 1  # False: system has not been rebooted recently
  fi
}

# Sleep for 30 seconds only if the system has been rebooted recently
if has_recent_reboot; then
  sleep 30
fi

# Initialize a variable to track the last time the sound was played
last_played=0

# Monitor D-Bus messages
/usr/bin/dbus-monitor --session "interface='org.asamk.Signal'" | while read -r line; do
  # echo "$line"
  if [[ $line =~ (Body:\ |MessageReceived) ]]; then
    current_time=$(date +%s)

    # Check if the sound has been played in the last ten seconds
    if (( current_time - last_played >= 10 )); then
      /usr/bin/aplay /home/user/.sounds/incoming.wav
      last_played=$current_time  # Update the last played time
    fi
  fi
done

I don't recall where I got this but the point is that when an incoming message is received it plays a sound I can actually hear rather than the wimpy "bursting bubble" sound the Signal desktop client plays. And it worked fine until a couple of days ago. But now when I run it doesn't seem to do anything, and if I uncomment the '# echo "$line"' and run it then I get:

signal time=1737146270.556214 sender=org.freedesktop.DBus -> destination=:1.524 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
string ":1.524"
signal time=1737146270.556237 sender=org.freedesktop.DBus -> destination=:1.524 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
string ":1.524"

So it appears to connect and then disconnect almost immediately. Did something change in the last week or so that would cause this?

As an aside I never really liked using this method, for one thing it plays the sound if I send a message, and I only really wanted it to play if I received one, but also I just never really quite understood the script completely, especially the top part which I guess is trying to prevent it from playing the sound if the sound is already playing? But anyway it seems you can't change the sound played in the Signal desktop client, and if there is any mechanism in signal-cli to play a sound when a message is received, I never could find it. I don't hear incoming message notifications if I can't play the louder, longer sound so any help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant