 I have a lot of programs installed on my Linux system because I do a lot of software testing and things for the YouTube channel, obviously, and I often install programs through a variety of different package management kind of systems, and a lot of package formats as well. I have things installed from the Arch repositories, from the AUR, the Arch user repositories. I also have snaps installed. I have some flat packs installed, and of course I have some app images. App images have become one of my favorite packaging formats because it's so easy to go grab an app image. You know, an app image is basically an archive. You just download an app image, you make it executable, and boom, the program will run. Like app images are super easy. I think really more Linux distributions should be pushing the app image format. I think app image really deserves to almost become like the default packaging format for Linux. I think it's that good. But I've never actually packaged anything myself as an app image. So I was reading through some of the documentation for it today and seeing, you know, how hard it would be to package some of my stuff as an app image and reading the documentation. It's really easy. Like anybody can package anything as an app image in literally minutes. So today on camera, I'm going to package my first app image. So since this is my first app image, let's package something really simple. A lot of people, when they are trying out a new package format for the first time, they'll package something really easy, like a basic bash script, you know, a simple shell script. Maybe all it does is echo, hello world. I don't want to do anything quite that easy. Let's actually package a real program. But again, let's not package something that's too complicated. So I think what I'm going to do is package my build of the ST terminal, the Suckless simple terminal. So let me switch over to my desktop and I'm going to open up a graphical file manager. I'm going to open up PC man FM. I imagine most people probably are going to do this using a graphical file manager. So open up your file manager and I'm in my home directory and in my home directory, what I'm going to do is I'm going to create a new directory here. I'm going to call it ST dash distro tube dot and I need to give it this extension. This extension is very important app, dear app directory. So app with a capital A, dear with a capital D and I'm going to click OK. And then let's go ahead and get into the ST dash distro tube dot app, dear directory. And then we need to create a couple of sub directories here. So the first one that we're going to create is us or user, although people pronounce it as user, it actually doesn't mean user. It actually means universal system repository or Unix system repository. Nobody's really sure exactly what it originally stood for, but it definitely does not stand for user. But the fact that it has three letters, us or everybody pronounces it as user when they're talking about the path. So I'm going to click on the user subdirectory and in it, I'm going to create another subdirectory and it's going to be been. So we've got slash user slash bin. Now as you've probably already guessed, what should go in slash user slash bin should be the binary of the program that you're creating an app image for. So let me go and grab the binary for my build of ST, I'm going to open up a new instance here of PC man FM and go into my build of ST here and somewhere in here is the binary right there. So I'm just going to copy that into that. So now that we've got the binary located in the correct location, let's go back up two levels here to the main directory. In my case, ST dash distro tube dot app deer. And we need to place three files in this directory. And the first file I want to place is a desktop configuration file, a dot desktop file because when you install applications, they need a dot desktop file or your Linux system to know they're there. So they're populated in like your menu system. So what you would do in a graphical file manager here is I could right click here and create new empty file. And I'm going to name this empty file ST dash distro tube dot desktop. So name it whatever it's got to end in dot desktop though. And then open that and whatever text editor you want to open that in, I'm going to open that up in Neo VM here. Let me fix the spacing here. Now creating a dot desktop file is pretty easy. The first thing you want to do is on the very first line do a opening and closing square bracket and inside the square brackets do desktop. If I can spell correctly entry. And you will notice desktop entry are capitalized capital D and desktop capital E and entry and then new line and then name and that is name with a capital N make sure you add the capitalization and I'm going to call this ST dash distro tube and then we need exec with a capital E. What is this executing? So what is the command that we actually are running? It needs to be in my case ST because that's the name of the binary. So that's the name of the program and then we need an icon and we actually did not put an icon in this directory but it is necessary to have an icon because again this is going to appear in your menu system if you have a like a graphical menu system and a panel you know and things like that. So we do need to give it an icon now it needs to be a ping dot PNG file and icon needs to be 256 pixels by 256 pixels. Now I just happened to have one. So I'm going to copy and paste ST dash 256 by 256 dot ping and if I actually didn't create this icon I went and googled terminal 256 by 256 and found a terminal icon and then I just named it ST dash 256 by 256 and so icon equals ST dash 256 by 256 dot ping and then on the new line here type with a capital T equals it needs to be application and then you can also add it to categories because you know in many menu systems they have subcategories of applications like is it a system utility or actually system and utilities are two different categories or is it an accessory or is it a game you know what kind of category should this be in the ST terminal I'm just going to claim it is a utility and then I'm going to go ahead and write let's go ahead and write and quit out of that. So we've got our desktop we've got our icon and there was a third thing we needed to add to this directory it needs to be a shell script and it needs to be titled app run. So once again create new empty file and then app run and just like the spelling of app deer you need app with a capital A and run with a capital R it's very important you get the spelling right and then let me go ahead and open that I'll open that in neo vm here and this is going to be a shell script so what I'm going to do is let's go ahead and add the the shebang here so it needs to be slash bin slash sh you could do slash bin slash bash obviously you're creating app images you're trying to create them as universal package formats so people that use the various bsd operating systems may want to use your app image as well they typically don't have bash installed so it's probably best to use slash bin slash sh for your app images now because this app run file is essentially what gets launched when you launch the app image I mean this is what executes everything this can be as simple or as complicated as you need it to be so if it was like a simple hello world kind of script you know I just need it to execute some simple bash script somewhere on the system you know I mean I could just do execute and then you know path to script you know something like that wherever you know that's just an example that it could be as simple as that or it could be much more complicated much more involved in you know hundreds of lines you could have if statements and case statements and while loops and all of that so what I'm going to do is I'm going to write a variable here I'm going to call it here all caps now I could name it anything but just for purposes of this video I'm going to have this variable here equals and it's going to be equal to a deer name read link dash f a dollar symbol zero what this is going to do it's going to basically get the location the directory of where this particular script is being executed and then let me go ahead and create a new line and other than that once we have that I really think I could do exec I'll do a variable exec all caps and then I think what I'm going to do is dollar symbol and then in the squirrely braces let's do here so it's getting that variable that we created with here slash user slash bin slash st so that's basically just the path to where that st binary is and then finally let's actually execute and whatever we're going to execute let's execute the exec variable from above and I don't know if this is going to work we'll find out now one thing we probably should do before we do anything else some of this stuff does need to be executable so the app run shell script that we just wrote let's make sure that is executable so in your graphical file manager you could just right click on it go to properties go to permissions and execute let's set that where anyone can execute it and then the dot desktop file probably needs to be executable as well so I'm going to click on properties on the the dot desktop file and make sure that that also is executable and then we're not quite finished there's one other thing we need to do we need to go and grab the app image tool if we don't already have it installed the app image tool is what you use to actually build the app image itself the archive so the app image tool there's a couple of different ways I could go and get this installed I could go grab it from it's actually hosted on github it's called the app image tool all one word you could actually download an app image of the app image tool for those of you that are on arch Linux or an arch based system like I am on arco linux what I could do is simply install it from the AUR so in my case I could install it with a AUR helper like paru or if you use yay look for app image tool dash min in the AUR now I've already got the app image tool installed so once that's installed what we need to do is we need to do app image tool and then the location to where that app deer is so we're already in my home directory and that is where the app deer is so let's do app image tool and then st dash distro tube dot app deer and let's run that now that failed and it failed but the good thing it looks like the app image tool actually tells us exactly why it failed it says the icon name in our desktop file st dash 256 by 256 dot ping that is the correct name for that file but it tells me I do not need an extension in the icon name so let's get back into the desktop file here which was st dash distro tube dot desktop and let me once again open that and let me go up here to the icon and let's just go ahead and get rid of the dot ping let's write and quit out of that and then get back into the terminal and once again let's run the app image tool on the app deer and once again I get an error it says a valid architecture with the ARC environment variable should be provided so once again there is an error but it tells me exactly what to do what I need to do is specify the architecture it even suggested for me that I needed x86 64 which is what I'm trying to build 64 bit so now that I've got that I'm going to go ahead and specify that and then once again let's do app image tool and then st dash distro tube dot app deer and that time no errors were returned so we should have successfully created our app image if I did a ls there should be st dash distro tube dash x86 64 dot app image that's the app image if you wanted to see it in the graphical file manager let's go to the home directory here and let's go down to st dash distro tube dot app image now we anytime you download an app image it will automatically run unless you have made it executable it looks like it's already set it to be executable so moment of truth let me click on this app image and see if it actually runs it's asking me do I really want to execute this I do do I want to integrate it and run it as part of the app image launcher I have the app image launcher installed on my system it kind of manages my app images for me if you don't have this installed you won't see this I'm just going to tell it to run once and there is the st terminal so it actually did work correctly so now I have my personal build of st packaged as an app image now I could take that thing anywhere anytime I want to distro hop I could take my own personal app images with me these aren't app images I necessarily have to share with the world and this thing literally wants you know how to create one of these app images it takes seriously like less than five minutes you know maybe three minutes you know if you're doing basically copy and paste jobs if they're very similar in form now packaging things for arch is pretty easy I've created a lot of different arch package builds it's not complicated right I've got some stuff in the a u r you know some of my own programs that I have in the a u r packaging for arch is pretty easy packaging for snaps pretty easy as well I'm sure packaging a flat pack isn't very difficult either but you know what app images I don't think it can get any simpler than what I just did packaging that app image I really think this should be more popular than it is I don't understand why we as the Linux community aren't promoting app image more because snaps and flat packs I know why they're so popular because snaps have a corporation kind of pushing that format canonical the company behind a boon to flat packs have a corporation kind of pushing that technology red hat right nobody's really pushing app image because it's a community project but we the community need to do a better job of pushing app images now before I go I need to thank a few special people I need to thank the producers of this episode absy Dallas Gabe Lou Mitchell Alan Akami Archvig 530 Chuck David the other David Dylan Gregory Lewis Paul Polytech Scott Stevens men Wes and Willie they are the producers of this episode without these guys this episode about creating portable applications using app image it wouldn't be possible the show is also brought to you by each and every one of these ladies and gentlemen as well all these names you're seeing on the screen right now these are all my supporters over on patreon because the distro tube channel is sponsored by the community I don't have any corporate sponsors so I do ask you guys for your support look for distro tube over on patreon all right guys peace now I just need to package emacs as an app image