{"id":15833709,"url":"https://github.com/itzmeanjan/pynotif","last_synced_at":"2025-04-01T12:26:18.264Z","repository":{"id":106438388,"uuid":"163093626","full_name":"itzmeanjan/pynotif","owner":"itzmeanjan","description":"DIY ( yeah ) notification API, with notification sound support ( using vlc backend ) :wink:","archived":false,"fork":false,"pushed_at":"2020-04-05T09:55:36.000Z","size":191,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-06T13:41:40.422Z","etag":null,"topics":["desktop-notifications","display-notification","gcc","gnome-desktop","libnotify","linux-desktop","notification","notification-api","notification-sound","python-api","vlc"],"latest_commit_sha":null,"homepage":"https://itzmeanjan.github.io/pynotif/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itzmeanjan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-25T15:29:26.000Z","updated_at":"2020-04-05T09:56:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"7887c63f-d4ad-4301-9250-beb2e1bf4ace","html_url":"https://github.com/itzmeanjan/pynotif","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fpynotif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fpynotif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fpynotif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fpynotif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itzmeanjan","download_url":"https://codeload.github.com/itzmeanjan/pynotif/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246637805,"owners_count":20809683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["desktop-notifications","display-notification","gcc","gnome-desktop","libnotify","linux-desktop","notification","notification-api","notification-sound","python-api","vlc"],"created_at":"2024-10-05T13:41:41.094Z","updated_at":"2025-04-01T12:26:18.243Z","avatar_url":"https://github.com/itzmeanjan.png","language":"C","readme":"# pynotif\n\nAnother Python API for accessing `libnotify`, along with notification sound support _( with `vlc` backend )_.\n\n![notification](ss/screenshot.png)\n\n**Caution : _Well you've to go through a rigorous installation prodecure, which may not be a preferred choice always. But it's pretty assured, you'll get to learn something new._** :wink:\n\n## setup\n\nI'll demonstrate installation procedure on `Solus Linux`.\n\n### prerequisites\n\n- Make sure you've `gcc`, `glibc`, `glibc-devel` installed. I'll use `gcc 9.3.0`.\n    ```bash\n    $ sudo eopkg it gcc, glibc, glibc-devel\n    $ gcc --version # check version\n    ```\n- Python3.x _(x\u003e=7)_ required. For installing `Cython`, we'll install `pip` too. I'm using `Python3.7.6`.\n    ```bash\n    $ sudo eopkg it python3, python3-devel, pip\n    $ python3 --version\n    $ python3 -m pip install --user Cython\n    ```\n- Let's install `libnotify`, `libnotify-devel`, which will be giving us programmatic interface for talking to libnotify from our C-library.\n    ```bash\n    $ sudo eopkg it libnotify libnotify-devel\n    ```\n- Well you can send notification from terminal using\n    ```bash\n    $ notify-send \"Summary\" \"Body of Notification\"\n    ```\n- Last but not least `vlc`, which will be used for playing notification sound, might be helpful for alerting user.\n    ```bash\n    $ sudo eopkg it vlc vlc-devel\n    ```\n\n### installation\n\n- Let's first go to a convenient location in directory hierarchy of your machine, where you can clone this repo \u0026 start working.\n    ```bash\n    $ git clone https://github.com/itzmeanjan/pynotif.git\n    ```\n- Get into `pynotif` directory and check content of directories.\n    ```bash\n    $ cd pynotif\n    $ tree -h\n    .\n    ├── [4.0K]  libnotification\n    │   ├── [2.4K]  play_sound.c\n    │   ├── [  45]  play_sound.h\n    │   ├── [2.4K]  send_notification.c\n    │   └── [ 235]  send_notification.h\n    ├── [1.0K]  LICENSE\n    ├── [4.0K]  pynotif\n    │   ├── [1.5K]  pynotif.pyx\n    │   └── [1.1K]  setup.py\n    ├── [7.0K]  README.md\n    ├── [4.0K]  sound\n    │   ├── [ 30K]  button_sound.wav\n    │   └── [ 29K]  when.mp3\n    └── [4.0K]  ss\n        └── [ 71K]  screenshot.png\n\n    4 directories, 11 files\n    ```\n\n- First we're going to `libnotification`, which is going to be compiled into a static C-library. File names are pretty self-explanatory, for what purpose they serve.\n\n    ```bash\n    $ cd libnotification\n    $ ls\n    play_sound.c  play_sound.h  send_notification.c  send_notification.h\n    ```\n- Time to compile each of these C files and generate object code.\n    ```bash\n    $ gcc -c play_sound.c\n    $ gcc -I /usr/include/glib-2.0/ -I /usr/include/gdk-pixbuf-2.0/ -I /usr/lib64/glib-2.0/include/ -c send_notification.c\n    ```\n\n- Now we need to archive these object files into a static library, which will be invoked from `Cython` code _(*.pyx file)_.\n    ```bash\n    $ ar rcs libnotification.a play_sound.o send_notification.o\n    ```\n\n- As we've obtained static library, compiled object codes can be removed now. You may consider checking kind of generated static library.\n    ```bash\n    $ rm *.o\n    $ file libnotification.a\n    libnotification.a: current ar archive\n    ```\n\n- Now we'll get into `pynotif` directory, which holds cython code, required for talking to C-library, `libnotification.a`.\n    ```bash\n    $ cd ../pynotif\n    $ ls\n    pynotif.pyx  setup.py\n    ```\n\n- `pynotif.pyx` holds cython code for interfacing with `libnotification.a`, which is to be compiled into equivalent C code _( using Cython compiler )_. Then we'll build C extension library _( dynamically linked library )_, which can be invoked from Python.\n    ```bash\n    $ python3 setup.py build_ext --inplace\n    Compiling pynotif.pyx because it changed.\n    [1/1] Cythonizing pynotif.pyx\n    running build_ext\n    building 'pynotif' extension\n    creating build\n    creating build/temp.linux-x86_64-3.7\n    x86_64-solus-linux-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -mtune=generic -march=x86-64 -g2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -fno-semantic-interposition -O3 -falign-functions=32 -I/usr/include -mtune=generic -march=x86-64 -g2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -fno-semantic-interposition -O3 -falign-functions=32 -fPIC -I/usr/include/glib-2.0/ -I/usr/include/gdk-pixbuf-2.0/ -I/usr/lib64/glib-2.0/include/ -I../libnotification/ -I/usr/include/python3.7m -c pynotif.c -o build/temp.linux-x86_64-3.7/pynotif.o\n    x86_64-solus-linux-gcc -pthread -shared -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions -Wl,--sort-common -Wl,--copy-dt-needed-entries -Wl,-O1 -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=0x1000 -Wl,-Bsymbolic-functions -Wl,--sort-common build/temp.linux-x86_64-3.7/pynotif.o -L/usr/lib64/ -L../libnotification/ -L/usr/lib64 -lvlc -lnotify -lnotification -lpython3.7m -o /home/anjan/Documents/my_programs/still_working/open/pynotif/pynotif/pynotif.cpython-37m-x86_64-linux-gnu.so\n\n    $ tree -h\n    .\n    ├── [4.0K]  build\n    │   └── [4.0K]  temp.linux-x86_64-3.7\n    │       └── [203K]  pynotif.o\n    ├── [125K]  pynotif.c\n    ├── [146K]  pynotif.cpython-37m-x86_64-linux-gnu.so\n    ├── [1.5K]  pynotif.pyx\n    └── [1.1K]  setup.py\n\n    2 directories, 5 files\n    ```\n\n- `pynotif.*.so` is our statically linked shared object, which is of interest. `./build` directory \u0026 `pynotif.c` can be deleted. But you might be interested in taking a look at `pynotif.c`, which is generated C code from `pynotif.pyx` by `Cython` compiler.\n    ```bash\n    $ rm build/ pynotif.c -rv\n    $ file pynotif.cpython-*.so # check it out\n    ```\n- Now you can use `pynotif`, but only from this working directory. Lets check that first.\n    ```bash\n    $ python3\n    \u003e\u003e\u003e import pynotif\n    \u003e\u003e\u003e pynotif.__version__\n    '0.1.0'\n    \u003e\u003e\u003e pynotif.startNotif(b\"My Application\")\n    1\n    \u003e\u003e\u003e pynotif.sendNotif(b\"Summary\", b\"Body of Notification\", 2, 1, b\"/path/to/icon/file\", b\"/path/to/notification/sound/file\")\n    1\n    \u003e\u003e pynotif.stopNotif()\n    \u003e\u003e\u003e help()\n    help \u003e pynotif # shows you API documentation\n    ...\n    ```\n\n- But we want to make it available to all scripts installed on this machine, Don't we ? Then we'll install this library into some standard location.\n    ```bash\n    $ python3 setup.py install --user\n    ```\n\n- Now go to `$HOME` directory \u0026 invoke Python3 repl prompt.\n    ```bash\n    $ cd\n    $ python3\n    \u003e\u003e import pynotif # and it works as expected\n    ```\n\n- **Congratulations, you've successfully built \u0026 installed `pynotif` from C-library. Now use as you wish.**\n\n\nThanking you :wink:\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Fpynotif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzmeanjan%2Fpynotif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Fpynotif/lists"}