Как я могу запустить скрипт, когда получаю уведомление [dубликат]

Это должно обеспечить то, что требуется:

grep -q "oldstring" test.txt
if [ $? -eq 1 ]; then
    echo "newstring" >> test.txt
else
    sed -i 's/oldstring/newstring/g' test.txt
fi
12
задан 13 April 2017 в 15:24

9 ответов

Вам понадобится dbus-monitor

Скрипт будет выглядеть как

#!/bin/bash interface=org.gnome.Rhythmbox.Player member=playingUriChanged # listen for playingUriChanged DBus events, # each time we enter the loop, we just got an event # so handle the event, e.g. by printing the artist and title # see rhythmbox-client --print-playing-format for more output options dbus-monitor --profile "interface='$interface',member='$member'" | while read -r line; do printf "Now playing: " rhythmbox-client --print-playing done

Взято из https://stackoverflow.com/a/5345462/854477

12
ответ дан 17 July 2018 в 21:33

Вам понадобится dbus-monitor

Скрипт будет выглядеть как

#!/bin/bash interface=org.gnome.Rhythmbox.Player member=playingUriChanged # listen for playingUriChanged DBus events, # each time we enter the loop, we just got an event # so handle the event, e.g. by printing the artist and title # see rhythmbox-client --print-playing-format for more output options dbus-monitor --profile "interface='$interface',member='$member'" | while read -r line; do printf "Now playing: " rhythmbox-client --print-playing done

Взято из https://stackoverflow.com/a/5345462/854477

12
ответ дан 23 July 2018 в 22:11

Вам нужен dbus-monitor

. Скрипт будет выглядеть примерно как

#!/bin/bash

interface=org.gnome.Rhythmbox.Player
member=playingUriChanged

# listen for playingUriChanged DBus events,
# each time we enter the loop, we just got an event
# so handle the event, e.g. by printing the artist and title
# see rhythmbox-client --print-playing-format for more output options

dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
    printf "Now playing: "
    rhythmbox-client --print-playing
done

Взято из https://stackoverflow.com/a/5345462/854477

13
ответ дан 31 July 2018 в 19:32

Вам нужен dbus-monitor

. Скрипт будет выглядеть примерно как

#!/bin/bash

interface=org.gnome.Rhythmbox.Player
member=playingUriChanged

# listen for playingUriChanged DBus events,
# each time we enter the loop, we just got an event
# so handle the event, e.g. by printing the artist and title
# see rhythmbox-client --print-playing-format for more output options

dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
    printf "Now playing: "
    rhythmbox-client --print-playing
done

Взято из https://stackoverflow.com/a/5345462/854477

13
ответ дан 2 August 2018 в 12:35

Вам нужен dbus-monitor

. Скрипт будет выглядеть примерно как

#!/bin/bash

interface=org.gnome.Rhythmbox.Player
member=playingUriChanged

# listen for playingUriChanged DBus events,
# each time we enter the loop, we just got an event
# so handle the event, e.g. by printing the artist and title
# see rhythmbox-client --print-playing-format for more output options

dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
    printf "Now playing: "
    rhythmbox-client --print-playing
done

Взято из https://stackoverflow.com/a/5345462/854477

13
ответ дан 3 August 2018 в 16:57

Вам нужен dbus-monitor

. Скрипт будет выглядеть примерно как

#!/bin/bash

interface=org.gnome.Rhythmbox.Player
member=playingUriChanged

# listen for playingUriChanged DBus events,
# each time we enter the loop, we just got an event
# so handle the event, e.g. by printing the artist and title
# see rhythmbox-client --print-playing-format for more output options

dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
    printf "Now playing: "
    rhythmbox-client --print-playing
done

Взято из https://stackoverflow.com/a/5345462/854477

13
ответ дан 5 August 2018 в 02:16

Вам нужен dbus-monitor

. Скрипт будет выглядеть примерно как

#!/bin/bash

interface=org.gnome.Rhythmbox.Player
member=playingUriChanged

# listen for playingUriChanged DBus events,
# each time we enter the loop, we just got an event
# so handle the event, e.g. by printing the artist and title
# see rhythmbox-client --print-playing-format for more output options

dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
    printf "Now playing: "
    rhythmbox-client --print-playing
done

Взято из https://stackoverflow.com/a/5345462/854477

13
ответ дан 6 August 2018 в 18:56

Вам нужен dbus-monitor

. Скрипт будет выглядеть примерно как

#!/bin/bash

interface=org.gnome.Rhythmbox.Player
member=playingUriChanged

# listen for playingUriChanged DBus events,
# each time we enter the loop, we just got an event
# so handle the event, e.g. by printing the artist and title
# see rhythmbox-client --print-playing-format for more output options

dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
    printf "Now playing: "
    rhythmbox-client --print-playing
done

Взято из https://stackoverflow.com/a/5345462/854477

13
ответ дан 8 August 2018 в 23:18

Вам нужен dbus-monitor

. Скрипт будет выглядеть примерно как

#!/bin/bash

interface=org.gnome.Rhythmbox.Player
member=playingUriChanged

# listen for playingUriChanged DBus events,
# each time we enter the loop, we just got an event
# so handle the event, e.g. by printing the artist and title
# see rhythmbox-client --print-playing-format for more output options

dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
    printf "Now playing: "
    rhythmbox-client --print-playing
done

Взято из https://stackoverflow.com/a/5345462/854477

13
ответ дан 14 August 2018 в 13:18

Другие вопросы по тегам:

Похожие вопросы: