Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Extended mode with bash script #22

@x09

Description

@x09

Hi,

i tried use scriptable-notifications with bash ;)

  • extended mode
  • connectionless
#!/bin/bash 

# read stdin from stdin (skip first 4 bytes)
readarray -t meta < <( tail -c+5  | jq '.message.author, .message.subject, .message.folder.name, .message.read'|  sed -r "s/\"|<|>//g")

from=${meta[0]}
subject=${meta[1]}
folder=${meta[2]}
readed=${meta[3]}

# skip if already readed
if [[ "xxx$readed" == "xxxtrue" ]]; then
        exit;
fi

        msg="${folder}\nFrom: ${from}\nSubject: ${subject}"
#send to tg
        tgsend -t 'mytoken' --chatId='mychatid' -m "$msg"
    

i see few procceses like this

anton 3060469 3059986 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}
anton 3060470 3060469 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}
anton 3060577 3059986 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}
anton 3060578 3060577 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}
anton 3060747 3059986 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}
anton 3060748 3060747 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}
anton 3060795 3059986 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}
anton 3060796 3060795 0 10:13 ? 00:00:00 /bin/bash /home/anton/bin/thunderbid-notify/notify.sh /home/anton/.mozilla/native-messaging-hosts/scriptableNotifications.json {271e72b1-166c-471b-bc06-41e03f176b15}

but messages to tg not sending..

if connecting to this any process with strace, i see wait/read syscall

[anton@dell thunderbid-notify]$ sudo strace -p 3060796 
strace: Process 3077447 attached
wait4(-1, 

^Cstrace: Process 3077447 detached
 <detached ...>

[anton@dell thunderbid-notify]$ sudo strace -f -p 3060747
strace: Process 3077445 attached
read(0, 
[anton@dell thunderbid-notify]$ cat /tmp/tb-notify-Lyyod | tail -c+5 | jq

{
  "accounts": {
    "account1": {
      "identities": [
        {
          "email": "shevtsovay@mymail.com",
          "label": "",
          "name": "Anton Shevtsov",
          "organization": "Base"
        }
      ],
      "name": "shevtsovay@mymail.com",
      "type": "imap"
    },
    "account22": {
      "identities": [],
      "name": "RSS",
      "type": "rss"
    },
    "account2": {
      "identities": [],
      "name": "Local folders",
      "type": "none"
    }
  },
  "folders": [
    {
      "accountId": "account1",
      "favorite": true,
      "name": "Inbox",
      "path": "/INBOX",
      "totalMessageCount": 2058,
      "type": "inbox",
      "unreadMessageCount": 1,
      "seenMessageCount": 0
    },
    {
      "accountId": "account1",
      "favorite": true,
      "name": "redmine",
      "path": "/redmine",
      "totalMessageCount": 12607,
      "unreadMessageCount": 0,
      "seenMessageCount": 0
    }
  ],
  "event": "read",
  "message": {
    "author": "Anton Shevtsov <shevtsov.anton@gmail.com>",
    "ccList": [],
    "date": "2025-01-09T11:10:29.000Z",
    "flagged": false,
    "messageId": "CAH92KP2mZEbn1pg8OEP4-ArDOoMFnKSv5RrJypQmWQQtXH9fsw@mail.gmail.com",
    "headersOnly": false,
    "junk": false,
    "junkScore": 0,
    "read": false,
    "size": 3330,
    "subject": "qwe",
    "tags": [],
    "folder": {
      "accountId": "account1",
      "name": "Inbox",
      "path": "/INBOX",
      "type": "inbox"
    }
  }
}
[anton@dell thunderbid-notify]$ cat /tmp/tb-notify-Lyyod | hexdump -C |  head -2
00000000  1f 04 00 00 7b 22 61 63  63 6f 75 6e 74 73 22 3a  |....{"accounts":|
00000010  7b 22 61 63 63 6f 75 6e  74 31 22 3a 7b 22 69 64  |{"account1":{"id|

But if start manually, all work fine

[anton@dell thunderbid-notify]$ cat /tmp/tb-notify-Lyyod | /home/anton/bin/thunderbid-notify/notify.sh

What i can do wrong?

p.s. After close thunderbird all messages will be sent to tg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions