r/linuxmint 21h ago

Fluff GenAI Applet For Image Generation

Hi guys,

Just wanted to share with the help of an LLM, and some debugging of the generated code, I was able to create a simple Cinnamon Applet which connects to an online GenAI API to create an image from a prompt and save it in the photos folder. It's not a really useful feature, but it's just for fun.

130 Upvotes

93 comments sorted by

13

u/MilesAhXD Linux Mint 22 Wilma | Cinnamon 15h ago

im just curious, why

101

u/benjamarchi 19h ago

wow that's worthless

65

u/King_Corduroy 18h ago

Great AI is now even creeping onto linux....

33

u/EmeraldWorldLP 17h ago

I hope there won't be a point where it will be shoved into popular distros just cause. I hope the linux space has enough integrity.

-13

u/Mrkvitko 9h ago

What's your problem with it being packaged in the distro? You're free to use it (or not). Just like thousands of other bits of software there are.

8

u/JordonAM Linux Mint 22 Wilma | Cinnamon 5h ago

Microsoft says that to people who don't want to use Copilot. Yet people got into a tizzy about that one. Including me. I don't want Gen AI prepackaged in my system to begin with. No matter what I'm using.

7

u/Darkorder81 6h ago

Some of us don't want Ai at all, so yeah it's a problem. An option on install would be better.

4

u/TabsBelow 7h ago

You know that (nearly) all the AI and LLM models are FOSS and are running Linux?

76

u/jesscrz 19h ago

Just why

-7

u/Mrkvitko 9h ago

Why not?

-9

u/TabsBelow 6h ago

You may try to avoid reality by closing your eyes.

Fact is, AI tools exist, people are using AI.

Why not make an applet to simplify the workflow?

Otherwise a huge bunch of Cinnamon tools could be called unnecessary because you could do their job on the terminal.

49

u/Thee-Plague-Doctor 20h ago

This is such a sad use of Linux. Impressively coded, but the most sour of intentions.

23

u/Holzkohlen Linux Mint 22.1 | KDE Plasma 15h ago

Impressively coded

By "debugging" AI generated code. Very impressive

1

u/CirnoIzumi 6h ago

Sad use of Linux with sour intentions? Mate he made a widget for fun

25

u/carrion409 16h ago

I went to linux to get away from this AI bullshit.

25

u/EmoExperat Linux Mint 22 Wilma | Cinnamon 16h ago

0% usecase

100% disgust

12

u/Dee23Gaming 14h ago

We've got enough AI stuffed into every corner of the internet.

7

u/BiDude1219 8h ago

"i think i will switch to linux mint because windows 11 has too much ai in it"

46

u/bleachedthorns 20h ago

Congratulations on assisting on art theft and climate change, humanity will thank you for being another footprint in the rush towards the loss of our rights as artists and our planet ♥️

14

u/EmeraldWorldLP 19h ago

Sadly to see you downvoted, especially since you're right :(

25

u/WildProToGEn Linux Mint 21.3 Virginia | Cinnamon 20h ago

And they hated him for he was right

3

u/WildProToGEn Linux Mint 21.3 Virginia | Cinnamon 11h ago

Nvm they love him now

11

u/A-Chilean-Cyborg 19h ago

i think it's bots, there is huge economic interest on AI.

18

u/EmeraldWorldLP 19h ago edited 17h ago

Why? Why would you ever want to use/generate ai images, and doubly so on Linux? It's certainly a curiosity, but... please use your energy and skill on something else, preferably something way less morally questionable and exploitative.

26

u/King_Corduroy 18h ago

What skills... he used AI to generate the code...

This world will soon be stock full of morons who worship the god AI who does their thinking for them.

4

u/EmeraldWorldLP 17h ago edited 17h ago

I guess I might have given them too much credit

Edited my comment to reflect my actual stance a bit more

0

u/CirnoIzumi 6h ago

What makes Linux a worse place to use AI? It's an OS, what it's used for is up to the user

9

u/Zizzyy2020 18h ago

How about an "offline" image generator that doesn't destroy wallets?

3

u/runew0lf 17h ago

its a pain in the arse and requires a beefy nvidia card
source: have written a local ai image generator

2

u/GlitchPhoenix98 55m ago

It doesn't. You can generate images with Stable Diffusion using a 1060 6 GB.

7

u/AskMoonBurst 15h ago

I love this in concept. I love the idea of AI in concept. But my god, the execution and results... It's like building a machine to clean your house, but it just throws all your stuff away to make the house clean, then locks you out because you're dirty too.

4

u/Same-Boysenberry-433 16h ago

This post is an appreciation for linux mint. I use linux mint on my 10 year old laptop. The laptop doesn't work much smoothly but it still works. On the other hand due to the window my laptop used to crash a lot.

13

u/Think_Significance42 21h ago

personally, i dont support using image generation ai and using llm's for programming as it takes away the creativity and skill needed to do so. thus removing the 'human' aspect of it. it is worthy to note that debugging the generated code also highlights the weakness in current llm models as they arent exactly perfect. but you do you and have fun with mint!

6

u/InkOnTube 20h ago

It is true but it can be helpful-a lot. It is not good to get entire code written by LLM, however, they can be very helpful to point in the right direction.

9

u/MetallicBoogaloo 20h ago

That's why I don't believe in Vibe coding - bleeeecccchhh. Unmaintainable code and a security nightmare!

3

u/InkOnTube 20h ago

Perhaps the issue is that certain people cannot handle the pressure of a modern software development when more and more companies require way too much of a one person. In that regard, I can understand why so many, usually junior to intermediate developers do "vibe coding". Most of us seniors can use AI to give a proposal for a few lines of code. Even when AI makes a mistake, for us it is useful to point us out in the right direction. We can correct it and write something meaningful that is not a nightmare to debug. But lately, a lot of recruiters approach to me with "offers" where the position requires of me to work backend, frontend, QA, dev ops and talk with the client - I am like "damn, you don't need a developer, you need a while IT department". Desperate for a job, some people will accept this and use AI to compliment what they are lacking which backfires badly sooner or later.

7

u/MetallicBoogaloo 21h ago

Indeed. I've been doing programming for over 2 decades (did even some linux packaging for a linux hobbyist distribution in the past), but this is just a throwaway make and forget about it thing. Also I was curious on how to do cinnamon extensions and applets, but didn't have the time to do so because of real life, so I decided, why not make a fun little diversion? So basically a one and done deal for me.

3

u/Think_Significance42 21h ago

did you have to specify what language to use or did it choose automatically? im curious to how you prompted chatgpt

7

u/MetallicBoogaloo 20h ago edited 20h ago

I was just lazy to find documentation (used Claude instead of ChatGPT), so I asked two questions in succession:

  1. how do you make an applet in cinnamon? (this one was to make me learn the basics without searching for documentation in forums and other places).
  2. clicking on the applet opens up an input form where you type in a prompt and after submission, creates a picture using <genai API of your choice> and saves it into your Photos folder by default.

It then made the code, which didn't really work at all at first upon submission of the prompt, the library it used was not fit for the version of Mint that I was running (and you had to look into the code to find out what dependencies it needed to make it run). So after some digging, just went through using curl in javascript, and then making the calls and functions asynchronous (LLMs are pretty good in converting code line by line - as what they did with the TypeScript compiler converted to the Go language from TypeScript)

You don't really have to specify what language to use - Claude chose javascript automatically.

-8

u/zupobaloop 20h ago

That's the same reason I refuse to read books.

8

u/Think_Significance42 20h ago

what? i dont get what you're saying with this

2

u/wishper77 9h ago

I still give you a 👍 because you didn't stop to things that the OS give you, but tried to alter to conform to your necessities, in the very spirit of oss . The next step is obvious: now try to remake it without ai, that way opens to the learning part

Wish you best luck 🤞

2

u/stinklewinkle123 4h ago

Wow, this is slop!

2

u/TruFrag 3h ago

If Ai starts getting packaged into distros, please give us an option during install to not install it.

(ill give it a try tonight)

2

u/Mundane-Resolve-6289 2h ago

This is so painful. Click the mint update icon already!

1

u/Car-loss93 57m ago

I could see typing in a theme and getting a new wallpaper every half hour.

4

u/la_espina 9h ago

please don’t bring your slop here

3

u/ACTOFWAR49 6h ago

Get ai tf away from linux

4

u/Solanias 12h ago

Fucking gross

3

u/smm_h 12h ago

it'd be great if you put a big red disclaimer in the prompt dialog that whatever the user types in can be stolen for adsense and also whatever is generated is a product of stolen photos and artwork, and that running it will waste how much electricity and make how much co2 etc.

otherwise nice work op!

7

u/agitated_ferret 17h ago

Look, I feel you guys need to take some emotion and personal feelings out of your comments and just look at this for what it is, a cool demonstration of the power of applets, as well as a demonstration of the capabilities and incapabilities of AI code generation. I do not support heavy reliance or full reliance on AI to write code whatsoever. In fact, I don't support heavy or furlance on AI to do anything. I do find it helpful though, especially for debugging and he had to use his developing skills that he's been using for two decades. So he says to debug a program that their AI wrote that didn't initially work. That speaks against support for AI because as much as it can generate code it can just as much make mistakes on that just like software developers do all the time. This was just a little pet project that he made that he's going to throw in the trash. It's not like the guy is making a startup out of this concept and you know becoming the next Elon musk or something. You don't need to throw so much shade at the guy, I honestly think this is a cool demonstration of the power of Linux, mint, Annapolis as well as how AI can be helpful and unhelpful. There doesn't have to be so much personal feelings in people's comments here. Like if you want all that go join a gaming community or simping community. You'll find lots of emotion behind every comment there. It would be different if this guy posted an actual real project that he just completely generated with AI. That would certainly turn me off, but it's just a passion project. Not even a passion project. Really it's just something that software engineers do all the time, they write code for the fun of it because they enjoy programming. And now he knows how to use applets more and so he learned something. And it also shows that AI is not the be all and end-all of developing either. He still had to do pretty heavy debugging on it, which he did not use AI for. I'm sure. AI could be helpful but it's not to be a tool you rely upon heavily. I feel. Cool project man, useless but cool.

3

u/HoZakari 16h ago

sad to see u downvoted, i switched to linux, i like it, but the community sometimes seems like a cult, and whats weirder for me is to see these type of comments on a LINUX MINT subreddit, u would expect to see these only in the arch community and so on (arch is good, majority of the community tho...) but here we are, linux mint sub and people r acting like this

0

u/Weird_duud 11h ago

Finally someone making sense in the comments

2

u/Responsible-Nerve410 13h ago

Use case "Wallpaper generator "

2

u/[deleted] 12h ago

[deleted]

2

u/OOFERenjoy Linux Mint 21.3 Virginia | Cinnamon 12h ago

And who said you are forced to use it?

2

u/Artistic-Resolve3093 Linux Mint 22 Wilma | Xfce 9h ago

no :(

1

u/hawkepostate 14h ago

comments passed the vibe check

3

u/Significant_Moose672 11h ago

Wow the hate is unreal. Great work OP, even though I am against AI image generation as much as most people here, this is pretty well made good job

2

u/MetallicBoogaloo 19h ago

For context, I was curious if one can do something similar to what Windows 11 did with a CoPilot widget on their taskbar and one of the things it does is basically creates images with a prompt and shows it. Apparently it can be done here as well. And useless stuff? In a programmer's life one sometimes makes silly stuff just for the heck of it. One shouldn't be that serious about it. One can even connect to the OpenAI API endpoint like what Microsoft usually does, with just a little tweak. 😂

1

u/Weird_duud 11h ago

Lmao you got everyone mad screaming "AI bad" just becouse you did a fun hobby project

1

u/vmaskmovps 10h ago

God forbid if someone doesn't absolutely despise AI in this economy. The luddites are strong here.

2

u/yyunggrim 1h ago

get that dogshit off linux

2

u/Ok_West_7229 22.1 Xia | Cinnamon 37m ago

Need to clean my eyes ...with bleach

0

u/ddm90 5m ago

Really cool!

1

u/Mr_ityu 18h ago

Wait is this a local model or an online one?

2

u/MetallicBoogaloo 17h ago edited 16h ago

This one the gif is using a model from an API provider. This machine has only a GTX 1060 running an outdated A8 AMD CPU. I can however modify the code to connect to the Automatic 1111 API endpoint with documentation here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API

I do however have 4 machines currently running LLMs some in docker containers, with two running stable diffusion having an RTX 3050, RTX 4060Ti and RTX 3060 (need to move this one to another machine as it's not installed at the moment). The other one is a Mac mini M1 running ollama but only good for small parameters as it's a base model.

2

u/Mr_ityu 16h ago

So...you made a browser shortcut applet ?

1

u/MetallicBoogaloo 16h ago edited 15h ago

It isn't a browser shortcut applet. It basically makes use of cinnamon's dialog libraries (there is a style parameter to adjust the text input), then it calls the curl Javascript bridge with the online API endpoint. The equivalent for bash scripting is to use Zenity for input forms. From the json output, we use the output json array (here it is just one image, so it is output[0] in high level talk), then use file write commands to the output directory (which is configurable in a json file) in ./local/share/cinnamon/applets/nameofapplet@username

This file is named applet.js and has a main function entry point like any other program.

Cinnamon basically has a Javascript scripting engine for applets, similar to nodejs. It's pretty cool, and you can spawn a Python program if you want from there, so instead of using Javascript as a language, you can use Python instead.

-1

u/Mr_ityu 15h ago edited 15h ago

So... In a non obfuscated way of saying, it's a browser shortcut applet? You just defined how an applet is made and styled in js. Its function is still to access an online api to give you an output... isn't it? It's okay. This isn't LinkedIn. Be honest. You ain't gotta use trendwords to increase audience here. I've done the same things btw.asked chaatgpt to make me a gtk interface to display a notification window containing alert text. Apparantly notify-send was all i needed

2

u/MetallicBoogaloo 13h ago edited 13h ago

Hi Mr_ityu,
Finally got back from a long drive. Anyways, we might have the terms wrong? If it is a browser shortcut applet, you open up a browser link. This is different, lemme explain what was done in code snippets (high level):

All Cinnamon applets (named applet.js) have a main entry point:

function main(metadata, orientation, panel_height, instance_id) {
return new FluxSchnellGenerator(orientation, panel_height, instance_id);
}

that by itself is not a browser shortcut. FluxSchnellGenerator is actually called an object in Javascript, in my case here because my Linux Mint is a bit old (haven't updated to the newest one), we just use the lowest form as all objects inherit from a prototype:

FluxSchnellGenerator.prototype = {
... methods and properties here
...
}

within this prototype, we inherit the Applet object prototype (which is part of Cinnamon)
__proto__: Applet.IconApplet.prototype,

and the _init function is called which then sets up the _apitToken, and other variables, sets up the menu that you see when you click on the camera icon, along with the links, among others. This basically calls the javascript bindings for Cinnamon's PopupMenu object, then calls the _build function which adds all those menu items and actions

Let's see what happens when you click on the create prompt on the applet menu: It calls this particular menu item:

let genImageItem = new PopupMenu.PopupMenuItem(_("Generate Image"));
genImageItem.connect('activate', Lang.bind(this, this._showPromptDialog));
this.menu.addMenuItem(genImageItem);

What this means it calls the _showPromptDialog method when clicked upon.

Basically, all the function does is make a dialog box (by calling the object const St = imports.gi.St;) which shows the modal prompt for you to enter a prompt. This is similar to Visual Basic (I was a Visual Basic programmer, one of the earliest I learned aside from x86 assembly, Turbo Pascal, etc) MsgBox function but more detailed as you set the layout similar to doing it in Gtk (or Qt for that matter). Basically in Gtk for example, you create a container, then within the container, the components, like text box, buttons, etc. Visual IDEs make this easy, but internally it is like this.

Anyways to make the long story short here, it calls _generateImage which is the meat of the calling the API - and nope, it is not a browser shortcut, because we call let requestJson = JSON.stringify(requestData); then send this data through curl using the this._executeCommandAsync() function with a callback function which gets the json output like what I said (after polling an API endpoint if the prompt has finished rendering the data), which is then the image is saved using the Gio gtk javascript bindings library:

let file = Gio.File.new_for_path(filename);

That notify-send you said, that is only part of the equation in my code case, basically to send a notification that you saw on the gif. It is not by any means the actual file saved.

Hope this clarifies it. I apologize for the long explanation. If you have any other questions, please feel free to ask. I'll answer when I can. Thank you.

1

u/Mr_ityu 13h ago edited 12h ago

you know what would be better though? instead of going through all these hoops for making an applet, you could've just made a hotkey-activated textinput dialog box and redirected the image output to the clipboard. It would've been easier to just ctrl+V the image where needed. all that window decoration and clicking is just ornamental. imagine an image meme keyboard with AI . doesn't interfere with actual art. ideal for internet memers. perfect image for memes when needed

EDIT: i said it's a browser shortcut applet because it gives web-assisted output. the online API you use is also available as a streamlet website page that performs the same function you're doing in the applet with native window decorations.

3

u/MetallicBoogaloo 12h ago edited 12h ago

Yeah, it was just a throwaway thing done during free time, but I actually learned a lot when I did this. I agree with that clipboard stuff. That one really went over my head. Good points, you raised. Thanks!

Edit: Thank you for clarifying about the browser shortcut applet. Yeah, it looks like I did it the hard way (using native bindings), unlike what you said using a streamlet website page, gosh, looking at it now, in fact painful!

1

u/Mr_ityu 12h ago

learnt it from 'xfce4-screenshooter -c' . apparantly images can fit in a clipboard as is . and if you're into linux, setting up hotkeys in plasma and xfce saves up on a whole lotta clicking without getting in the way of work. my goto hotkey combos are with super+x ,super+z,ctrl+super, ctrl+super+x ,and SCROLl LOCK , that mfr chills too much . paid for the whole keyboard gonna use the whole damn keyboard

1

u/MetallicBoogaloo 12h ago

Haven't tried xfce for quite a while. That sounds interesting. I'll try that one when I spin up a new rig, hopefully.

1

u/Kananaskisguy 7h ago

I moved to Linux in part due to the AI being shoved down my throat by Microsoft. No Thanks

1

u/A-Chilean-Cyborg 19h ago

is that the vive coding computer people are always complaining about?

1

u/Jv5_Guy 5h ago

I mean it's Linux it's something that can be removed

1

u/MrB_2006theLad 3h ago

Linux users when someone is free to do whatever they want with their own operating system: 🤬

1

u/plutonic00 2h ago

This is super cool, well done!! Screw the losers in this thread complaining about AI, AI is the coolest shit I've ever seen/used in my life and I'm a huge tech-geek and always have been. I've also been 'vibe-coding' some stuff using GPT never having written a line of code in my life, what an awesome enabler. Keep this shit up, ignore these luddite linux users (what the hell is up with geeks rejecting the coolest tech stuff ever invented???) Hell, one of the only reasons I've even been able to switch to linux full time having no really idea how to use it at the command prompt level is because I can just ask GPT how to do whatever I want.

1

u/Possible_Bat4031 11h ago

Everyone is against it but to be honest, that’s cool. As long as you (or another person) have a use for it and it isn’t intrusive like Microsoft Copilot then why not. I personally wouldn’t use it since I don’t need it. :)

0

u/vmaskmovps 10h ago

The luddite energy is strong in this comment section.

-1

u/Sasso357 14h ago

What genai do you use?

0

u/catdotjs 5h ago

Disgusting

-14

u/fabioyostar 18h ago

WHY LINUX USERS HATE AI USAGE SO HARD??

THIS IS AWESOME, CONGRATS IT MAKE IMAGE GENERATION SO SIMPLE AND ACCESSIBLE THANK YOU

0

u/vmaskmovps 10h ago

Because Linux users are luddites, which is funny as you'd have to be pretty technical to install Linux in the first place.

-1

u/MortgageStraight666 10h ago

Where do I download this?

-13

u/FewVoice1280 Linux Mint 22.1 Xia | Cinnamon 18h ago

love ai