Sunday, November 6, 2011
Wednesday, July 6, 2011
Verbosity
If this was a wall of text you would probably not have read it. "Brevity is the soul of wit." <- worth remembering for future writing.
Tuesday, June 7, 2011
Tutorial: Plasma+QML
In this tutorial I will attempt to teach you how to write a simple plasma widget using qml technology. I hope you find this informative! And I am sure some of the expert plasma widget developers will be able to offer some excellent additions to this tutorial in the comments! Before you start, I'd recommend you familiarize yourself with QML using this site: QDeclarative Introduction
(This post has some color coded sections, I am not sure that they will render properly on the planet, so if you feel you the color coding would help and you can't see it you may have to come to the blog itself.)
I. Setting Up
First thing is first, we need to setup the directory where we will be creating the widget.
Now we've set up the basic file structure for the widget. You'll notice there are only two editable items in what we've created, the .desktop file and the .qml file. The .desktop file will contain basic information about the plasma widget. The .qml file is where we will put the actual code for the widget. More complex plasma widgets will likely have more files in them.
II. metadata.desktop
Set the contents of the metadata.desktop file as follows.
The second block deals with what type of widget it is, where the main script is, how big the default widget size should be. If it was written in python it would say "X-Plasma-API=python"
The remaining blocks are mostly self explanatory please refer to techbase.kde.org for more information.
III. main.qml
Now to the meat and potates of the whole thing. What you all have been waiting for, the actual code that does something!
import Qt 4.7
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
1. import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
IV. Testing
Now lets test this! Using a console go into the "plasma-qml" directory and enter the following command: plasmoidviewer
This should give you a preview of your plasmoid. If there is an error it will display that instead, read the error and find the offending code and fix it.
V. Installing
To install this we would go to the console. Inside the "plasma-qml" directory enter the following command: plasmapkg -i ./
Next run kbuildsycoca4 by entering the command in a console (I'm not sure if this always necessary).
Now you can add the Plasma-Qml widget like you would any other! Congratulations you have created and installed your first Plasma widget!
As an exercise try making a calculator widget.
IV. References
I used the following tutorials and this one is based on them. Please use them for more information. In general techbase.kde.org is your main resource for kde development.
Techbase Plamsa/QML
Techbase Plasma/Javascript
For more on QML examples
Update:
From Daker Fernandes Pinheiro: "It's important to let clear that once the Plasma Components http://codecereal.blogspot.com/2011/05/plasma-components.html is ready, the QWidgetProxy solution will be deprecated. These components must follow a common API: http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-200. As I explain in the post, many of these items already can be used, and I'm planning to integrate the done components in master branch in a few weeks."
(This post has some color coded sections, I am not sure that they will render properly on the planet, so if you feel you the color coding would help and you can't see it you may have to come to the blog itself.)
I. Setting Up
First thing is first, we need to setup the directory where we will be creating the widget.
- Create a directory with the name of the widget we will call ours in this example "plasma-qml"
- Create a text file inside this directory called metadata.desktop
- Create a directory inside the plasma-qml directory called "contents"
- Create a directory inside "contents" called "ui
- Create a text file inside "ui" called "main.qml"
Now we've set up the basic file structure for the widget. You'll notice there are only two editable items in what we've created, the .desktop file and the .qml file. The .desktop file will contain basic information about the plasma widget. The .qml file is where we will put the actual code for the widget. More complex plasma widgets will likely have more files in them.
II. metadata.desktop
Set the contents of the metadata.desktop file as follows.
[Desktop Entry]The first block deals with the name, description, and icon of the plasmoid. This is important for what users will see when they are trying to add your plasmoid.
Name=Plasma-QML
Comment=A test widget for Plasma using QML
Icon=chronometer
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-DefaultSize=200,100
X-KDE-PluginInfo-Author=Ahmed Ghonim
X-KDE-PluginInfo-Email=zrchrn@gmail.com
X-KDE-PluginInfo-Website=zrchrn.blogspot.com
X-KDE-PluginInfo-Category=Examples
X-KDE-PluginInfo-Name=org.kde.Plasma-qml
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-ServiceTypes=Plasma/Applet
Type=Service
The second block deals with what type of widget it is, where the main script is, how big the default widget size should be. If it was written in python it would say "X-Plasma-API=python"
The remaining blocks are mostly self explanatory please refer to techbase.kde.org for more information.
III. main.qml
Now to the meat and potates of the whole thing. What you all have been waiting for, the actual code that does something!
import Qt 4.7
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
Item {The main differences between this and the QML examples you read about are:
id: 'item'
PlasmaWidgets.PushButton {
id:btn1
anchors { left: parent.left
bottom: parent.bottom
top: parent.top
}
text: "This is a Button!"
onClicked: {print("hello Konsole") ; lbl.text= " hello label"}
}
PlasmaWidgets.Label {
id: lbl
anchors { right: parent.right
bottom: parent.bottom
top: parent.top
left: btn1.right
}
text: " This is a Label!"
}
}
1. import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
this line imports Plasma's graphicswidgets such as PushButtons and Labels so that we can use them in our widget.
2. PlasmaWidgets.PushButton (also PlasmaWidgets.Label) these aren't QML widgets so we must have the import line listed above to use these.
Please feel free to ask questions in the comments section about the rest of this code I feel that would be easier than attempting to explain it which would probably be better done in a QML specific tutorial and most of which has been adequately done in the linked QML tutorial. IV. Testing
Now lets test this! Using a console go into the "plasma-qml" directory and enter the following command: plasmoidviewer
This should give you a preview of your plasmoid. If there is an error it will display that instead, read the error and find the offending code and fix it.
V. Installing
To install this we would go to the console. Inside the "plasma-qml" directory enter the following command: plasmapkg -i ./
Next run kbuildsycoca4 by entering the command in a console (I'm not sure if this always necessary).
Now you can add the Plasma-Qml widget like you would any other! Congratulations you have created and installed your first Plasma widget!
As an exercise try making a calculator widget.
IV. References
I used the following tutorials and this one is based on them. Please use them for more information. In general techbase.kde.org is your main resource for kde development.
Techbase Plamsa/QML
Techbase Plasma/Javascript
For more on QML examples
Update:
From Daker Fernandes Pinheiro: "It's important to let clear that once the Plasma Components http://codecereal.blogspot.com/2011/05/plasma-components.html is ready, the QWidgetProxy solution will be deprecated. These components must follow a common API: http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-200. As I explain in the post, many of these items already can be used, and I'm planning to integrate the done components in master branch in a few weeks."
Tuesday, May 24, 2011
Fedora 15
Fedora 15 is out! I highly recommend the KDE spin for those who like a simple, unbloated KDE based OS. http://spins.fedoraproject.org/kde/
Wednesday, May 11, 2011
I need a new distro version 2
Recently I've been surveying a lot of KDE distros. I tried a lot of live cds and looked at a lot of videos and screenshots. Things have changed a little bit since I last searched for a distro. People have started modifying KDE (KDESC?) a bit more from the defaults but not by much certainly nothing that compares to how much Gnome2/Kde3 were/are customized. In any case I eventually decided I had to settle on something. So I went to my s.o.p for distro selection. Make a list and use each distro long enough to decide if it was something I could use with minimal annoyance. Here are my findings so far.
OpenSuse:
I received a great many suggestions for OpenSuse and Arch Linux (and Chakra). I tried OpenSuse 11.4/Tumbleweed. I had many issues with OpenSuse 11.4 unfortunatly. I thought perhaps switching to Tumbleweed would fix them but no cigar. The one thing that sticks in my mind is that my ability to click would randomly stop (yes that is click on buttons). I could use keyboard shortcuts and buttons etc. would work then. Very odd, especially in light of OpenSuse 11.4 getting so much praise which I'm sure is well deserved. There were a lot of great things that I respect about OpenSuse and I certainly respect anyone's decision to use it. However I moved on.
My next distro was going to be Arch. I have a great many good memories of my time on Arch. Almost every thing I learned about Linux I learned using Arch. However I felt the time to set everything up and take care of all the little kinks might be too much so I decided to try Fedora ahead of Arch.
Fedora is my "alma matter" the first distro I ever installed, and in my opinion currently the best gnome distribution out there and given current my experience, I might even say it has the best KDE spin I've tried so far. It's not so much that it does anything special with KDE, it provides basic vanilla kde (though Fedora 15 has an awesome ksplash!). Perhaps that is the beauty in it, nice and simple (they don't even split the kde packages). So far no problems I was able to get to work with minimal setup time.
My reasons for leaving Kubuntu were initially based on the fact that ubuntu had managed to introduce a bug in natty that led to my laptop overheating. This issue managed to resolve itself soon after my decision to switch and the latest Kubuntu release is actually pretty good. However I decided to take the opportunity to try something new.
So it is that I'm currently sticking with Fedora and so far I am quite pleased. If that changes then I still have Arch, PCLinuxOS and Mageia.
OpenSuse:
I received a great many suggestions for OpenSuse and Arch Linux (and Chakra). I tried OpenSuse 11.4/Tumbleweed. I had many issues with OpenSuse 11.4 unfortunatly. I thought perhaps switching to Tumbleweed would fix them but no cigar. The one thing that sticks in my mind is that my ability to click would randomly stop (yes that is click on buttons). I could use keyboard shortcuts and buttons etc. would work then. Very odd, especially in light of OpenSuse 11.4 getting so much praise which I'm sure is well deserved. There were a lot of great things that I respect about OpenSuse and I certainly respect anyone's decision to use it. However I moved on.
My next distro was going to be Arch. I have a great many good memories of my time on Arch. Almost every thing I learned about Linux I learned using Arch. However I felt the time to set everything up and take care of all the little kinks might be too much so I decided to try Fedora ahead of Arch.
Fedora is my "alma matter" the first distro I ever installed, and in my opinion currently the best gnome distribution out there and given current my experience, I might even say it has the best KDE spin I've tried so far. It's not so much that it does anything special with KDE, it provides basic vanilla kde (though Fedora 15 has an awesome ksplash!). Perhaps that is the beauty in it, nice and simple (they don't even split the kde packages). So far no problems I was able to get to work with minimal setup time.
My reasons for leaving Kubuntu were initially based on the fact that ubuntu had managed to introduce a bug in natty that led to my laptop overheating. This issue managed to resolve itself soon after my decision to switch and the latest Kubuntu release is actually pretty good. However I decided to take the opportunity to try something new.
So it is that I'm currently sticking with Fedora and so far I am quite pleased. If that changes then I still have Arch, PCLinuxOS and Mageia.
Monday, May 2, 2011
KDE: Unity Setup
First some screens:
You are looking at a picture (within a picture) both showing my crude 10 minute implementation of Ubuntu's Unity layout by customizing plasma. There was 0 code involved here on my part. It get's basically similar functionality to unity (not everything obviously) and it has both a composited mode and a non-composited mode that you can switch seamlessly between as an added advantage. I think the Ubuntu team should have started with kde technology I feel it would have made their lives much easier and this is a platform that is powerful and would have saved a lot of effort.
How to-ish:
Basically you add the Window Menu bar widget to a panel. Then you move the panel to the top. You add a second panel to the left with a task bar widget in it. Tweak the size and make it autohide. Also, notice that the Title Bar disappeared in the full screen window. Well you can do that with any window manually but with a little handy work, you can actually have kwin hide the title bar when you maximize the window. (This is one of the areas that would require work to reach unity's level of functionality though as no window controls go into the panel.
- kate .kde/share/config/kwinrc
- add: BorderlessMaximizedWindows=true
Sunday, April 17, 2011
I need a new distro
At long last it is time to part with my Ubuntu/Kubuntu setup. As a result I am taking suggestions for a new distro.
My needs are:
-Binary Package management (no gentoo :( )
-It must be laptop friendly.
-It must not hate FGLRX
-I would like a vast package selection, again I'm not a fan of compiling everything from source.
+bonus for distros that are not too bulky and are very innovative.
Please also add some information on what makes that distro unique. I'm really looking for *stability* and performance, without the stagnation. I've considered debian stable but I don't know if kde 4.6 would be making it's way into back-ports (I'm really not familiar with debian processes). I'm not too optimistic about that as debian seems to be content with kde 4.4 in it's "unstable" repos.
My needs are:
-Binary Package management (no gentoo :( )
-It must be laptop friendly.
-It must not hate FGLRX
-I would like a vast package selection, again I'm not a fan of compiling everything from source.
+bonus for distros that are not too bulky and are very innovative.
Please also add some information on what makes that distro unique. I'm really looking for *stability* and performance, without the stagnation. I've considered debian stable but I don't know if kde 4.6 would be making it's way into back-ports (I'm really not familiar with debian processes). I'm not too optimistic about that as debian seems to be content with kde 4.4 in it's "unstable" repos.
Wednesday, April 6, 2011
Congratulations to the GNOME
Congratulations to the GNOME team for launching GNOME 3 today. I know it's been a long time comming for them. I'm sure this is just a first step for them on a long and hopefully successful journey. Once I try it I will try to post a detailed analysis of it (Much can be learned about KDE by looking at it's alternatives!) but today is for congratulations to a fellow Open Source project!
You can learn more about GNOME 3 here: http://www.gnome.org/gnome-3/
You can test it using the live Fedora CD here (or OpenSuse!) : http://www.gnome.org/getting-gnome/
Sadly, last I checked you cannot test GNOME 3 in virtual box.
For those of you who have tried it, lemme know what you think. What did you like, what did you hate?
You can learn more about GNOME 3 here: http://www.gnome.org/gnome-3/
You can test it using the live Fedora CD here (or OpenSuse!) : http://www.gnome.org/getting-gnome/
Sadly, last I checked you cannot test GNOME 3 in virtual box.
For those of you who have tried it, lemme know what you think. What did you like, what did you hate?
Friday, April 1, 2011
Announcing KDE-Panels!
In my a recent blog I talked about the best layout possible for pushing the Desktop. After careful deliberation I've come to realize that the single most successful Desktop feature is Panels. The beauty of panels is they put everything at your fingertips. So the idea is to frame the desktop with panels and put every single application, folder, and widget on to the 4 panels.
Initial Concept!

Masterpiece of Efficiency Realized!

As you can see, this setup puts everything at your fingertips and you can still work comfortable on 4 applications at the same time. You never have to wade through endless menus or use clunky file managers to navigate folder after folder. So if you are typing some code and you need to reference a document, just open the document without using a file manager by simply clicking on the link on the right Panel. In less than 1 second you go from "stimulus" (I need to open this file) to "result" (Your document will be opened). This allows for addicting computing. As users will be able to get anything they want opened instantly. In turn having everything on their computer visible all of the time will lead to a barrage of stimuli activating their brains and helping them to be constantly using more of the files and applications on their computers rather than letting them rot.
The best part is most of the technology we need is already here! To the future!!!
Thursday, March 31, 2011
The Failure of Open Source (and how we can save it)
The problem with open source is that it is inherently weak. It's fun for hobbyist, sure. But the more I think about it the more I feel like as long as open source projects operate under the delusional idea that they will be able to compete on the open market, much less put out products that are better than the big companies such as Apple, Google, Facebook, and Microsoft we will fail. The GNU is a licence for commercial failure. It's an idealistic document that only works in the land of unicorns, like communism. Corporations that attempt to do business while adhering to the goals of open source are doomed to fail. They will always be outmaneuvered by bigger corporations that can just steal their code, modify and improve it and then sell it. No one will be the wiser to their exploits because their source will be closed so FOSS companies won't know their code is stolen. So the few times that the Open Source community will get ahead the gains will be short lived.
That rarely happens though because most of the time is wasted in FOSS communities arguing thinks like which toolkit is better Gtk or Qt or wxwidgets. Vi vs Emacs vs Nano vs Kate. KDE vs. XFCE. Gnome 3 vs Duke Nukem Forver. (Duke Nukem Forever wins, it's actually going to be released just read Vincent's blog about gnome 3). In short, Open Sources as a viable commercial enterprise is bad. It "strengthens our enemies and weakens the resolve of our allies"
So what's the solution you say? I'm glad you asked, the solution is the brand new FOSS for L33ts Initiative. The best thing that we can do is recognize we are writing for hobbits and hobbyists and no one else. So we need to get rid of GUIs, they are very un-l33t. We should keep the cool things though. So we can have a cube switch from each virtual console. So ALT+F2 leads to a nice cube effect. More over, we absolutely keep the wobbly windows idea. As you are not deserving for Foss L33t-ness unless you have wobblies on your desktop. But because there will be no more windows we must instead have wobbly progress bars that wobble all the text on the console every time the progress increases by 1% and the wobble should get more and more intense as you approach 100%. We need to get rid of binary distributions as they are inefficient. It takes 0.032 seconds more for applications to start working when you don't hand compile them using special flags such as -034 & -L33t-speed, which are computer and user specific. Which is a tremendous waste of time. Compiling programs from trunk ever time you have to use them is much more efficient and thus l33t.
Also, rebooting your computer should be fun again. In order to do that the kernel needs a Russian-roulette algorithm that uses a random number generator to determine if "rm -rfv /" is run immediately after booting (in verbose mode so that losers of the game get to watch in agony!).
We need to take back FOSS from all the people that want to use the community to make money for the big corporations!!! And this is the way to do it!
Disclaimer: The Contents of this post are only valid on this day and month. And will only be so in an annual fashion. By reading this sentence you also agree to empty your bank account to fund the new FOSS for L33ts Initiative. Thanks, have a nice day.
That rarely happens though because most of the time is wasted in FOSS communities arguing thinks like which toolkit is better Gtk or Qt or wxwidgets. Vi vs Emacs vs Nano vs Kate. KDE vs. XFCE. Gnome 3 vs Duke Nukem Forver. (Duke Nukem Forever wins, it's actually going to be released just read Vincent's blog about gnome 3). In short, Open Sources as a viable commercial enterprise is bad. It "strengthens our enemies and weakens the resolve of our allies"
So what's the solution you say? I'm glad you asked, the solution is the brand new FOSS for L33ts Initiative. The best thing that we can do is recognize we are writing for hobbits and hobbyists and no one else. So we need to get rid of GUIs, they are very un-l33t. We should keep the cool things though. So we can have a cube switch from each virtual console. So ALT+F2 leads to a nice cube effect. More over, we absolutely keep the wobbly windows idea. As you are not deserving for Foss L33t-ness unless you have wobblies on your desktop. But because there will be no more windows we must instead have wobbly progress bars that wobble all the text on the console every time the progress increases by 1% and the wobble should get more and more intense as you approach 100%. We need to get rid of binary distributions as they are inefficient. It takes 0.032 seconds more for applications to start working when you don't hand compile them using special flags such as -034 & -L33t-speed, which are computer and user specific. Which is a tremendous waste of time. Compiling programs from trunk ever time you have to use them is much more efficient and thus l33t.
Also, rebooting your computer should be fun again. In order to do that the kernel needs a Russian-roulette algorithm that uses a random number generator to determine if "rm -rfv /" is run immediately after booting (in verbose mode so that losers of the game get to watch in agony!).
We need to take back FOSS from all the people that want to use the community to make money for the big corporations!!! And this is the way to do it!
Disclaimer: The Contents of this post are only valid on this day and month. And will only be so in an annual fashion. By reading this sentence you also agree to empty your bank account to fund the new FOSS for L33ts Initiative. Thanks, have a nice day.
Thursday, March 10, 2011
Design Decisions #1
I want to thank who ever it was that made the decision to NOT force KDE to develop a composited desktop with a fall-back to a totally different looking un-compositied desktop in the event the computer has a driver failure/poor videocard. (Edit: I know kde has compositing, but those are effects and the overall design of kde looks basically the same whether you have the compositing on or off).
I say this in light of the development work on Unity and Gnome3. Which falls back to gnome2 when 3d acceleration is not available. Why? The people developing their software are going to develop it with the "new model" in mind. However, when the thousands of previously happy linux users whose hardware is not up to these new standards try to use this new awesome software. They won't get the same experience the developer had in mind. I cannot imagine that the gnome3 developers will continue to actively work on things with the gnome2 based desktop. Ubuntu in the past couple of releases has done some pretty nice things to gnome2. However they seem to have determined that gnome2 was indeed on its way to the history books and went with a netbook setup for a desktop (???).
In Unity's "defence" they are working on a "Unity2D" desktop. However, that uses QT unlike the default "3d"Unity. While I have to admit I'm not entirely familiar with this decision, it seems to make little sense. It seems to now require twice the effort because they have to code the same interface in 2 different toolkits??? Why not just make all of Unity in Qt? Or just use plasma to design something new. I've been waiting for this since plasma came out. Interestingly enough distros seem hesitant to play with the default kde look (I'm sure many in KDE support this). So every time I try a new kde distro I get the same bar at the bottom with a folderview in the desktop. So perhaps the winner here might be Kubuntu if they decide to make a "kubuntu-Unity" using plasma. (Feel free to prove me wrong here).
In any case I think I might try messing with the default KDE setup and posting the results. And if you have screenshots of cool kde4/plasma desktops that look unique please share them with me! (I'm getting kind of bored with the windows-esq setup of a taskbar+panel+window launcher setup at the bottom.) I would like to say that I am a fan of the KDE-netbook interface, and I'd like to see some equally cool new setups for the desktop.
/* This is mostly an opinion/impression based post that I hope to follow up with more analysis based posts that deal with design. These will likely focus more on kde design than a lot of these other DE's but may include "plasma implementations" of some of the better design decisions in other DEs. */
I say this in light of the development work on Unity and Gnome3. Which falls back to gnome2 when 3d acceleration is not available. Why? The people developing their software are going to develop it with the "new model" in mind. However, when the thousands of previously happy linux users whose hardware is not up to these new standards try to use this new awesome software. They won't get the same experience the developer had in mind. I cannot imagine that the gnome3 developers will continue to actively work on things with the gnome2 based desktop. Ubuntu in the past couple of releases has done some pretty nice things to gnome2. However they seem to have determined that gnome2 was indeed on its way to the history books and went with a netbook setup for a desktop (???).
In Unity's "defence" they are working on a "Unity2D" desktop. However, that uses QT unlike the default "3d"Unity. While I have to admit I'm not entirely familiar with this decision, it seems to make little sense. It seems to now require twice the effort because they have to code the same interface in 2 different toolkits??? Why not just make all of Unity in Qt? Or just use plasma to design something new. I've been waiting for this since plasma came out. Interestingly enough distros seem hesitant to play with the default kde look (I'm sure many in KDE support this). So every time I try a new kde distro I get the same bar at the bottom with a folderview in the desktop. So perhaps the winner here might be Kubuntu if they decide to make a "kubuntu-Unity" using plasma. (Feel free to prove me wrong here).
In any case I think I might try messing with the default KDE setup and posting the results. And if you have screenshots of cool kde4/plasma desktops that look unique please share them with me! (I'm getting kind of bored with the windows-esq setup of a taskbar+panel+window launcher setup at the bottom.) I would like to say that I am a fan of the KDE-netbook interface, and I'd like to see some equally cool new setups for the desktop.
/* This is mostly an opinion/impression based post that I hope to follow up with more analysis based posts that deal with design. These will likely focus more on kde design than a lot of these other DE's but may include "plasma implementations" of some of the better design decisions in other DEs. */
Saturday, February 19, 2011
Anyone else do this?
Ok, I admit, sometimes when I'm short on time, I look through planet kde looking only for posts with pictures of new features. :(
Subscribe to:
Posts (Atom)


