Extending GNOME Is HardEP 5: Tuesday, Jun 13, 2023
Mark Johnson 0:00
So I’ve been writing a gnome extension. Hmm, what
Martin Wimpress 0:07
feature was lacking from kinome that required you to write an extension?
Mark Johnson 0:11
Oh, where to begin? Oh, I, I just of course, the particular thing that I wanted to be able to do, which I couldn’t do, I have multiple audio outputs. In particular, I have some headphones, and I have some speakers. And I have it set up so that some applications output to my headphones for things like video calls, and some things like music and podcasts output to my speakers. But there isn’t a very easy way to control the volume of two different outputs in Nome, the best sort of solution that I can find is using the Pavlou control GUI. But it’s fiddly because it’s got loads of stuff in that appears and disappears depending on what’s going on. And having an app running all the time, just so that I can control volume sliders every now and then, is not terribly convenient. So I thought, wouldn’t it be nice if there was a way of having volume sliders for all of your outputs available instead of just the default output, which is what you get by default with GNOME, and KDE has this, but I didn’t really want to switch desktop just to get one tiny little feature like this. So I thought, after looking and realising that it didn’t seem to exist, I thought, Well, I wonder if I could write it myself. So I’d like to talk a little bit about the developer experience of writing a gnome extension. I don’t know if either of you two have ever delved into this?
Martin Wimpress 1:35
Alan Pope 1:37
Can I ask before you started developing? Did you look for an existing extension that already did this?
Mark Johnson 1:44
I did. I had a look on the no extensions website. And there was one which looked like it might have done it. But it was wasn’t compatible with current versions of gnome. And there were a few which did similar things, but not the same thing. It was like being able to switch the default output easily or control what different applications were doing, but not what different outputs were doing things like that. Right?
Martin Wimpress 2:07
And were any of those existing extensions useful in your sort of research as to how to go about this?
Mark Johnson 2:14
I didn’t look there at first, because I sort of wanted to try and start from first principles and follow documentation and find out what’s the right way to go about this kind of thing?
Alan Pope 2:26
And did you find documentation which told you what was the right way about going about this? Ah,
Mark Johnson 2:33
Alan Pope 3:32
So how do people find out how to do that, then?
Mark Johnson 3:35
That is something I’m not completely sure if I either I missing something, or people who write successful, useful gnome extensions? Are people who know quite a lot about gnome development in the first place, or do they just copy
Alan Pope 3:48
and paste and cargo cult from other extensions that already exist?
Mark Johnson 3:53
Alan Pope 5:57
Excellent. I do feel like it is a tried and tested path for early graphical user interface developers to create something basic, which just shells out to command line tools. And when you’ve got pa CTL, which can do this, it totally makes sense. There may be system calls that will be more efficient. I don’t know how efficient it needs to be changing the volume, you’re going to notice the latency when you slide that volume slider up and down or performance might be slightly better to use some system call rather than shelling out. But other than that, if it works, use it. Did your
Martin Wimpress 6:35
background as a web developer help you at all in this journey?
Mark Johnson 6:40
Alan Pope 7:08
And have you had any problems with it, not being able to enumerate the devices or numerating the wrong ones or turning the wrong devices up and down or any major user flaws.
Mark Johnson 7:19
Not yet. I mean, it’s very simple. At the moment, it just gets a list of all the devices you have whether you want them or not, and display stuff for them, I’d like to have some configuration to make it a bit more selective. So you could just have it show the ones you’re using. So that might be something I talked about in the future, how you go about adding settings and things like that. One thing I did find interesting was trying to debug this and work out what I was doing as I went, you can’t actually restart the extension without restarting GNOME Shell as a whole. But what you can do is run an embedded session, which appears in a little window and loads the whole desktop on all the extensions, including the latest version of your extension. And then you also get the log from your extension mixed in with all the other logs. So it’s a bit of a slog, trying to really nail down issues, but it is possible in a roundabout sort of way. And yeah, I suspect there’ll be more about this in the future. One thing I’d like to do next is look at the process for actually publishing this on the gnome extensions website. In the meantime, if you’re interested in seeing this is actually on my GitHub at github.com/marks Johnson slash advanced volume control,
Alan Pope 8:30
oh, it’s advanced, is it Wow, get you it’s more
Unknown Speaker 8:33
advanced than the one that you get out of the box.
Martin Wimpress 8:40
So after just over 30 years, I’ve decided to wean myself off Nano, nano is over 30 years old. That’s how long I’ve been using it. Yeah, you’re over 30 years old. I’m over 30 years old. And in fact, it’s not nano because originally I used to use Pico, right. And then nano is sort of the continuation or rather the good new free software implementation of the PICO editor. So this all started a long, long time ago in my first job where we had Unix servers and our email system was pine. And the default editor for pine was Pico. So from the very beginning when for my first introductions to Unix, I was familiar with the PICO editor and consequently, I never really used vim or VI or any of these vibe based editor’s because pico was where I started and I stuck with Pico and switched to nano when pico got rejected from you know popular distributions because of licence reasons, in the sort of mid 1990s. And in fact, most distributions you’ll find that nano is still sibling to Pico to this day. So I’ve been happily using nano as my terminal based text editor for all that time for the entire time. I’ve been using Linux as well, but I finally decided that it will It’s time for an upgrade something new or something more capable. So I’ve been making the switch.
Alan Pope 10:09
So in a previous episode, you talked about how you’re big into using Apple devices, and you’re using Apple Music for all your music needs. And now you’ve moved away from now and you don’t really use VI, are you really a geek at all?
Martin Wimpress 10:25
Yeah, one of my last jobs, there was a critical problem on one of the servers. And I was leading the ops team at the time and they dragged me over to help me poke around. And as I was looking around, I went and edited one of the files and I nano file name. And I heard someone behind me say freak it was lately considered the not using, you know, vi or vim to be, you know, a cardinal sin. But I don’t care nano has been perfectly serviceable. And it’s the it’s, I’ve only ever used it when I’m on a server. You know, I’ve always had some other editor that I use for development these days. It’s Visual Studio code. And this is one of the reasons why I decided to move away from Nano, what I found is, is that I use VS code so much I’m so familiar with the key bindings in VS code. When I open something in Nano, I often execute the wrong key bindings, and do bad things. And consequently, I’ll do the same in VS code sometimes and cut lines out of my text when I didn’t mean to. So I thought, right, I could rebind all of the keys in Nano, which you can do. But you know, the syntax highlighting is okay. In Nano. It’s not great. So I thought, I’m gonna go and have a look, see what’s out there has syntax highlighter,
Alan Pope 11:45
I keep forgetting that nano has syntax. Highlighting is not enabled by default. Right? And then every so often, I’ll see someone post a nano screenshot. Oh, yeah, you should enable that. And I keep forgetting. So no, I’ve, I think I’ve seen it like twice in my life.
Martin Wimpress 12:02
So it’s something that I have in my dotfiles is a nano RC with all of the well, I say all with a good selection of syntax highlighting, but it’s not great. Anyway, so here you go. And if you want to see some syntax highlighting in your terminal editor, I have switched to the terminal editor called micro. Ah, and I am very, very happy with it indeed. So the first reason for switching is that almost one to one, the key bindings in micro are the same as the default key bindings in Visual Studio code. So gone are the days of conflating which editor you’re in, and you know, doing the wrong thing, by and large, the same key combinations do the same things in both places. So that was sort of a big win. And also the syntax highlighting is absolutely brilliant. And I think it’s nearly 100 languages are supported. So I like that a lot.
Mark Johnson 12:59
Did you consider just using VS code, because I have on occasion, used it as a sort of SSH client with built in file manager and text editor. And it does a really good job of that if you just need to go into another machine and edit files remotely.
Martin Wimpress 13:16
I didn’t consider doing that. No, maybe I should have done.
Alan Pope 13:20
I too, have edited files on my home server thinking, God, I’ll just I’ll just mount it in the File Manager and then just drag the file into VS code. Because I’ve got the window open right now. And I can’t be bothered to press CTRL ALT T and then SSH and then Nano. I can it’s easier in Yeah, having Nautilus able to mount using sshfs or whatever it is. I know this stuff is built into VS code. But I wouldn’t like the backdoor way. But yeah, I can I can see how using VS code as your standard editor. Once you get used to it. You’re totally right. You just want to keep using it for everything.
Martin Wimpress 13:59
Yeah, gone are the days of me logging into sort of servers, I have a couple of devices around the house that I log into. But all of the stuff that’s you know, on the internet, I don’t log into those servers anymore. They’re all orchestrated in some fashion or another. So I don’t need to log into those and use an editor there. So it’s really only a couple of network infrastructure devices that I run on my land that I log into, sort of interactively over SSH. And micro is proving to be great for that. Some of the features of micro that I really like is you can do editor tabs and splitting so you can have a single edit window open and then split it across multiple files a bit like you can do with some of the terminal emulators that will do splitting. And it has a bunch of plugins, not many of which I’ve experimented with yet. But you can also do the multiple cursors thing as well, which is really cool. And it has excellent mouse support, which means you can just you know highlight your stuff and you Again, if you have a terminal window open to a thing with micro, you can easily copy and paste your stuff to an editor on your desktop because it all just happens seamlessly with you know the mouse. And you can do and this is a sort of a workflow that I have, which is for a longest time, I have the text editor IDE open and I always have a terminal window underneath. And I might use that to run a build script or maybe start an interpreter and do some interactive code snippet wrangling whilst I figure out what I want to put in the actual programme. And micro supports that as well. So you can actually open a terminal beneath the edit window in just the same way over and it also has a nice nano like Help menu system to help you get around and learn the thing. When you’re just starting out.
Alan Pope 15:52
I’ve just noticed that I do have G vim open right now on my laptop, because I have a gun, a GPG encrypted file with some secrets in it. And I have a plugin that I use with Vim, vim GPG, I think it’s just called something like that. But it automatically decrypt the file using Password in my key ring, and then re encrypt it when I you know, control wq. Whatever the right incantation, is it automatically re encrypts it, I would have thought if I could do that in Nano, that would be great. But I think I might give this micro ago I heard of it, because we made a snap of it many years ago, when we were both at canonical. And I played with it a little bit, but I wasn’t super looking for another editor. But if I could replace Vim and the the GPG automatic encryption thing, so I could edit encrypted files directly in micro that would be amazing. And I would love that,
Martin Wimpress 16:44
I think there may be a plug in to do what you require. And my final sort of motivation for switching to micro is I have been switching out lots of my common tools and utilities that I use at the in the terminal with so called Modern Unix alternatives. So I’ve completely embraced the modern Unix lifestyle and micro fits in with that uplifting and refitting sort of, you know, the comfortable place that you go to when you open a terminal, you mean it’s written in rust or go or something, I don’t know what language is written in. To be honest with you,
Alan Pope 17:20
I think it’s go, I have a feeling it’s
Martin Wimpress 17:24
I don’t really care about those implementation details, right. And I suppose the only thing is, is that when you’ve been using something for such a long time, muscle memory is really hard to shake. And to start with, I would micro file and then immediately use the Nano key bindings because my brain saw a terminal editor. And so the fingers default to using nano key binding. So it took a lot of effort to actually shake that behaviour. But more frustrating still is when I’d actually got my mind into I’m using micro now. When I was at the terminal, I wanted to edit something, the number of times nano file name came out my brains now thinking micro but I’m in nano and I still can control C and all the rest of it and the wrong thing happens. So I’ve now actually put an alias in my terminal so that when I type Nano, it actually runs micro now to prevent that confusion.
Alan Pope 18:23
Would you remove that now I don’t know if no no is in the default instal of whatever OS you’re using, but I guess you could just remove nano but that seems a bit brutal
Martin Wimpress 18:31
Nanos in the default for Nix OS. And Ubuntu is probably a bit much for some Ubuntu installations, but I’ll keep it around. But I am working very hard to just micro all the things now. And if you’re looking to change things up with a bit of modern Unix, then I highly recommend micro it’s rather Excellent.
Mark Johnson 18:54
Linux matters is part of the late night Linux family. If you enjoy the show, please consider supporting us on the rest of the late night Linux team using the PayPal or Patreon links at Linux matters.sh/support. For $5 a month on Patreon, you can enjoy an ad free feed of our show, or for $10 get access to all the late night Linux shows ad free. You can get in touch with us via email show at Linux matters.sh or chat with other listeners in our telegram group. All the details are at Linux matters.sh/contact.
Alan Pope 19:28
I want to tell you something I’ve learned while using Azkaban to, but I’m not going to tell you till the end. Okay. Okay, this is a Hear me out. So ask him to for those who don’t know is a question and answer system built on Stack Exchange like Stack Overflow. So people post questions, how do I fix this printer? Where do I get this driver? That kind of stuff? And then people in the community either search for answers and then give them a link to the answer and mark it as a duplicate or write an answer or write a comment asking for more information so that they can provide an answer, with the goal being to provide useful answers to support questions, and people can upvote the questions and they can upvote the correct answers and they can mark certain answers. As Correct. I’m sure everyone knows how stackexchange works. That’s exactly what ask Ubuntu is. It’s been around for 12, nearly 13 years, I think now started by George Castro and Marco Sheffy. And Evan D’Andrea, and a few other people at canonical and a whole bunch of people in the community. And it’s still going now. And it’s still super, super active. So we know what ask him into it. Yeah. So there’s some things you need to think about when we talk about technical support. And one of them is not everyone is an expert nerd. Some people just want to use a computer, they want to use it as a tool. And I think one of the problems that the people in the nerd space and I include us in that is we have a kind of blindness for those people who just want to use a computer. And they’re not like us, they’re normal, right? They just want to turn the computer on open the web browser, go to whatever it is they want to do, they might want to do some software development, they might want to do some video editing, whatever those workflows are, they want to do those things. And when it breaks, they’re a bit lost. And that is true no matter what operating system they’re using. That’s not unique to Linux. And not everyone wants to switch to arch. Arch isn’t a panacea that fixes all problems. It’s the same software underneath, right? It’s the same bits that have been compiled, maybe slightly newer, maybe slightly different. Maybe slightly faster. Who knows. But it’s still pretty much the same stuff, right? And when something breaks, people want to get it fixed, locked. So reinstall, and switching distro is not always the answer. It’s you want to get something fixed, right? So sometimes it is the answer. But often it isn’t. And one of the things that nerds need to understand is that people who have broken their system are often very goal oriented, and they want to get a thing done. And getting to that goal. That’s the destination, they want to get to they want to edit a video, print a document, send an email, create a presentation, whatever it is, they want to do that thing. And anything that gets in the way is a frustration to them. So often these people are quite frustrated, because something is not working the way it should. And they don’t understand why. And it should work. Why doesn’t it work. And there are often ways in which they solve these problems by going online and just copying and pasting stuff they find because they’re frustrated, and they don’t know any better. Right? A nerd will say, Oh, you don’t copy and paste off of the internet, you don’t download random packages, you don’t use that repo and all that kind of stuff. But they don’t know this, because they’re not part of the community. They’re just people using computers, right. And you might find some interesting ways in which people break their systems. And I’ll give you some examples of what I’ve learned a surprisingly high number of people due to NACA, their computer, and I mean, probably inaccurate, so it doesn’t, it doesn’t work and they need help. Installing random Deb’s without dependencies from third parties, for example. Their goal is I would like this piece of software that I have seen somewhere or I’ve heard of. And so the googling turns up a page, which has a link to a blog, which has a link to a Deb, they click the DEB they instal the dam and it breaks. And it might break. Because it’s a third party repository. It’s only built for an old version of Ubuntu, and there’s a missing library that they don’t have. Or it could be that they downloaded a Deb linked directly from a repository from an old version of Ubuntu. And it’s built against some ancient version of lib, SSL or lib C or something like that people do this.
Martin Wimpress 24:00
And as you’re saying all of that you’re exampling you being a nerd, and how this ancient decrepit software doesn’t even feature on the radar of the people that are trying to instal this stuff in order to get a task completed. They don’t understand why installing a Deb from an eight year old version of Ubuntu is a bad thing to do.
Alan Pope 24:21
Yes, I used to help this guy out many years ago in the days of DOS and Windows and there was a text editor he would use that he paid for. Now we’re talking a long time ago. And he continued to use that because he was using it to write programmes to run a milling machine that made little widgets out of strips of metal in his garage. Now, all the way through MS DOS all the way through windows, he used that same text editor running off of a floppy disk right because he was inclined not to change. He was familiar with this tool. And the same thing happens on Linux people get familiar with applications. They may not have a technology person nearby and their familiarity means that when they upgrade their system or they get a new laptop, they want that familiarity of that piece of software. And so they go hunting it down. And yes, they find it in some old repository, they’ll find an old wiki page or something like that. Because there’s that comfort of using a piece of software that you’ve been using maybe for 30 years, like a text editor. And so there’s a good example of the way in which someone could break their system or break an application on the system is just finding a random Deb off the internet and trying to instal it. Right. That’s, that’s straightforward and easy to understand. Another thing that does often find or are often incredulous about is that people remove software from their system. Like, I don’t know what that is. So I’ve removed it. And they could do that at the package level, they could apt remove, or they could use synaptic, or they could use some package manager and remove packages. Or they might be more brutal. And say, Oh, why is that taking up space, I don’t recognise what that is. And a little knowledge is a dangerous thing. Sudo RM, and then they wipe out all of that, and things like that. You can say, well, he’s being an idiot. He’s, you know, he’s removed all of ours that removed a crucial file, but they don’t know any better. And they’re not protected, because it’s their computer, and we give them the gun and the bullets. And if they want to shoot themselves in the foot, they can, and sometimes do often do
Mark Johnson 26:22
a patch. Interesting point about you saying, Yeah, this isn’t a unique thing with Linux. This is just how people use computers. There’s a interesting point that the developer of curl makes that sometimes antivirus software on Windows, flags, curl dot exe as being a vulnerability and people go into the Windows system directory and delete curl dot exe, and things break, because that’s the thing you can do.
Alan Pope 26:45
Yeah, yeah. In fact, you’ve reminded me of a guy, when I used to work at the local college, he removed the System folder from windows, now we’re talking nine, early to mid 1990s, like 93, I left that job. And he just deleted or moved the System folder into the recycle bin or trash or wherever you call it. And I was like, Well, don’t do that. And he’s like, why not? It was taking out loads of space. And this thing’s got a small hard drive. And it was running aspects. Why should I not taking out loads of space? And it’s like, this is an age old problem. Computers are very, very complicated things and software is very, very, very complicated. And there’s no guardrails to stop you doing that? Yeah, you could just like highlight a folder, Bennett. And it’s like, okay, well, you get to keep all the pieces now well done.
Martin Wimpress 27:27
So I think that there’s another interesting way to break your system, which fits into this perfectly, which is you have a problem, you find a solution to the problem that you have, that tells you to do a bunch of things. And you don’t understand the bunch of things that he’s telling you to do. But you do them anyway. And what you don’t realise is you’ve just started a time bomb ticking because you’ve actually created another problem that you’re going to experience at a future date as a result of the things that you’ve just done.
Alan Pope 28:00
Yeah, absolutely. That’s actually something that used to happen. In the old days in Ubuntu is, there was a piece of software called automatics. And it was a script that someone wrote, and it did loads of really wacky stuff. If you want to learn what it did go and find Matthew Garretts, tearing apart blog post of automatics. It did loads of crazy stuff like killed processes ran D package and apt with a minus y. So you know, just ran, it was hideous, and it would cause support nightmares, for those of us who have to help people who’ve run this stuff, and, and people do go and find these useful pieces of software, and then just run them and then it might not break now. But it might break in six months time when you come to upgrade your system. Or if you’re on an LTS, it might break in two years time. And you’ve got no idea what you did two years ago that broke this system. So it’s sometimes very hard to pick apart. You know, forensically figure out what it was that they did, especially over a web forum where you’re asking for detailed output of commands and stuff. It’s, it’s a hard problem to solve. And there’s other stuff like, you know, installing random kernels. And the big one that I’ve seen a lot recently is people updating the version of Python, they go and find a new version of Python and replace the system version of Python that breaks the world. It breaks, apt breaks, D package breaks, all kinds of things. Sometimes you’ll be left with a terminal, you won’t even be able to get into the desktop, others, you know, the packaging system just goes a bit wonky. But all of these problems, I think I’ve figured, like we’ve got a whole community of people who are willing to help these people and want to help these people. If you ask a question and ask him to most of the time, in under an hour, you’ll get an answer, or you’ll get questions for like more information. And that’s free. That’s volunteers giving their time for free to help you get out of the hole that you’ve got yourself in or the problem that you find in front of you. And it staggers me. It amazes me that people are willing to give it I’m one of them like I’ve been, I’ve got an active account on Ask Ubuntu for 12 years. And I’ve answered a lot of questions in my time. And I enjoy doing it. And I enjoy helping people. It’s the thing that gives me pleasure when we fix something and they say, yeah, that helps. That helps solve my problem. But the thing when I introduced this is I’ve learned and it’s taken painfully too long to learn is I think the answer to a lot of these questions is the immutable desktop, I really am coming round to this idea that not necessarily for everyone, and certainly not necessarily for every nerd. But for normal folk who are very quick on the trigger and able to break a system, doing things that the platform allows them to do, should probably be given an immutable desktop, so they are less likely to shoot themselves in the foot. Like it gives them the bullets but not the gun. And so they can probably unlock it. And you know, with all of these immutable systems, there’s buttons being pressed to make it so you can write to stuff and you can certainly still break it. And I’m not saying it’s perfect, but I certainly think there is room for a better way to distribute the Linux desktop, where we’re less likely to have people just trying to instal a new package, and it utterly hoses their system. And I completely off the mark, I think this might be the selling point for the immutable desktop,
Mark Johnson 31:36
I can imagine a situation where you have something like a default immutable setup where you instal Ubuntu. And by default, you can’t go and delete stuff from user slash lib. But if you are someone like us who knows enough to be dangerous, you can run a command or flick a switch like you can on Steam OS, for example, you may want to make your system writable which I haven’t on Steam, because I will absolutely no reason to I use it for playing games, not for screwing around. I have plenty of other systems for that. But you know, nerds like us who want to screw around can but people who want to get stuff done and don’t want a broken system won’t do it by accident, or are less likely or less likely, I suppose that the other the other problem is that what you end up with is is all of these things that say run these commands, the first command is run this command that says unlock your system and then paste all of this stuff into your terminal.
Alan Pope 32:34
Yeah, that certainly is a potential, you know, possible outcome of this is everyone just says, Well, the first thing you do is disabled the security system, which is exactly what happens on Red Hat when people complain about SC Linux. The first thing the first thing you do is disable SC Linux. And it was for a while when people had problems with snaps. A lot of the answers on Ask Ubuntu when someone said this thing doesn’t work. And the question will be how did you instal it? Was it a snap? If the answer is yes, they’d say remove the snap and instal the Deb. That’s actually less now because a lot of those problems have been ironed out. I think it will be like that. There will be a period of transitionary period where a lot of people will just say, I’ll just turn all that off, throw that away. But I think there is room for not hardcore nerds, but normal people to have a more pleasurable experience that isn’t so fragile
In this episode we discuss:
You can send your feedback via
firstname.lastname@example.org or the Contact Form. If you’d like to hang out with other listeners and share your feedback with the community you can join:
- The Linux Matters Chatters on Telegram.
#linux-matterschannel on the Late Night Linux Discord server.
If you enjoy the show, please consider supporting us using Patreon or PayPal. For $5 a month on Patreon, you can enjoy an ad-free feed of Linux Matters, or for $10, get access to all the Late Night Linux family of podcasts ad-free.