Programming Leftovers
-
Simon Ser: Status update, September 2022
This month I’ve been working on stuff I’d usually not work on willingly. And by that I mean Rust and screen tearing of course.
I’ve been randomly typing keys on my keyboard and before I knew it, a wlroots-rs repository was created. Everybody is saying how difficult (or even impossible) it is to write Rust bindings for wlroots so I wanted to see for myself and give it a try. One thing is clear: these people weren’t wrong. The first step was to wire up bindgen to automatically generate Rust declarations from the wlroots headers, and that was easy enough. Then I needed to figure out how to use libwayland’s intrusive linked lists (wl_list, wl_signal and wl_listener) from Rust. I took a while to build a basic example where a fixed wl_signal is listened to. Then it took more time to figure out a (hacky) way to abstract that into a re-usable helper. And now I’m stuck at trying to figure out a reasonable Rust API.
The main issue is that Rust lifetime concepts don’t map well to wlroots/Wayland. I’ve taken some inspiration from Smithay and introduced a BackendHandler trait which can be implemented by a compositor, and which has its methods called when a wlroots signal is emitted. This works nicely for simple cases, but sometimes signals are used to introduce new objects to the compositor (e.g. wlr_backend.events.new_output). Sometimes signals reference an existing object. If the compositor owns all wlroots objects, then wlroots can’t fire a signal referencing these objects. Also, the compositor would like to listen to signals on objects created by wlroots, e.g. wlr_output.events.destroy. My next try will maybe introduce some kind of wlroots object handle (and there can be multiple handles referencing the same wlroots object), but not sure how it’ll turn out. If you have any good ideas, please share! My latest work is sitting in the handler-v2 branch.
-
Hacktoberfest 2022 is near! | itcharlie [blogs.perl.org]
Every year in the month of October a company named DigitalOcean hosts an event named Hacktoberfest.
If you ever wanted to contribute to a Perl project now is a good time to give it a go!. Here are a few beginner friendly projects that are up-for-grabs.
-
Python Package Manager PIP Cheat Sheet for Linux
If you are new to the Python programming language or have some experience in navigating around popular programming languages, then you must have crossed paths with PIP.
The Python module installed on your Linux operating system distribution is associated with numerous packages and libraries that help lessen common hurdles affecting your Python projects.
To install such packages and libraries, we need the aid of Python PIP, which is a useful Python package manager that is effective in fetching, installing, and configuring needed Python packages and libraries.
The usage of the PIP Python package manager is not always clear and might require continuous internet searches to find the appropriate command syntax associated with it.
-
Python Command Line Parsing Tutorial
The parsing for command line arguments was formerly included in the default Python library “argparse”. By enabling user input values to be somehow parsed and then used, “argparse”. It offers flexibility and reuses your code in place of manually setting variables as part of the code.
-
BASH while loop explained with examples | FOSS Linux
Programming languages are built on a foundation of many core concepts, including loops. Loops come in handy when you need to execute a set of commands several times until a particular condition is met. Loops are a valuable tool for automating repetitive tasks and can be found in scripting languages such as Bash. The for loop, the while loop, and the until loop are the three fundamental iteration constructs in Bash scripting.
This guide will walk you through the fundamentals of using while loops in Bash. In addition, we will demonstrate how to change the course of a loop by utilizing the break and continue statements in the appropriate places.
In a Linux Bash script, the while loop ensures the script will continue to run so long as the condition that was programmed remains accurate. When you need to repetitively execute a set of commands a certain number of times, or when you desire to create an infinite loop, while loops are valuable tools to have at your disposal. To teach you how while loops in a Bash script are written and what kind of functions they perform, this tutorial will walk you through several example scripts that contain while loops.