r/rust•
balsoft

First useful project in Rust: simple-osd-daemons

I've been interested in Rust for about two years now, and I have read the rust book and written some "hello worlds" with it to get a feel for the language. Recently I've had a thought: my desktop running Sway was missing a nice feature of full-blown desktop environments: on-screen display notifications for volume, brightness and battery. So, after a quick hoogle to make sure there isn't a Haskell binding for pulseaudio, I've decided that the time has finally come to use Rust for something useful. Here is the result:

https://code.balsoft.ru/balsoft/simple-osd-daemons

(A github mirror: https://github.com/balsoft/simple-osd-daemons)

Screenshot of pulseaudio daemon

It consists of four daemons at the moment: volume via pulseaudio, screen brightness, battery and bluetooth via bluez (however, the bluetooth daemon doesn't really work, see README). Each daemon can be started independently of others. There is also a library of sorts in common subfolder, it contains utilities for managing configuration files and sending/updating the notifications via libnotify.

There are some problems that I intend to fix during the next weekend, but it works and it fulfills my needs so thought I would share it with you in case somebody needs this too!

I know there are probably some programs that do the same thing, but better. However, this is more of a learning experience for me. If you have any suggestions on how to improve this, reply here, shoot an email at [email protected] or open a ticket on github. All feedback, whether positive or critical, is appreciated.

EDIT: Now that I re-read the title, it might come across as though my little thing is the first useful project in Rust ever; this was not the intended meaning, but it's impossible to change the title. It should read "My first useful project in Rust".

Posted Sep 15, 2020, 6:33 PM UTC · edited

244
[deleted]•

Cool! I'll have to start using this!

1
pkunk11•

Maybe replace unsafe with Rc in the pulse daemon?

1
balsoftOP•

Actually, figured it out myself. Thanks for the suggestion!

3
balsoftOP•

I have fooled around with it for about half an hour before giving up and writing unsafe. If you manage to rewrite it with Rc without using unsafe, I'd be glad to receive the patch to [email protected] or on github.

2