Archive for the Category: '
Linux '

Windows 8 introduced the concept of a Windows “App”. This has moved forward through Windows 8.1 and Windows 10.

Effectively, these “Apps” are what was formerly referred to as “Metro” and is now called the Modern UI. They use something of a different interface paradigm, with different controls and with elements typically sized for easier touch-screen use. That’s all well and good.

With Windows 8, 8.1, and 10, using these Apps tends to be optional. For the most part, there are equivalents you can use. A good example is Control panel; there is a “Settings” App which has some options, but for the most part there is a overlap with the “old style” Control Panel.

Recently, however, I needed to open an App for whatever reason. Or maybe I opened it by accident. Rather than the app opening, me being annoyed, and then closing the App, it instead said “This app can’t open” and suggested that I perform a Refresh to fix it. This sent me down something of a rabbit hole- Searching online for fixes, trying them, getting weird results, etc.

Actually, I’ve jumped in the ring to wrestle these issues a few times- I’ve had it on at least one my systems for ages and it recently appeared on another. Being unable to make some changes to the system was annoying enough that I decided to fix the issue- which, again, sent me down the rabbit hole. Try this command. Try this other one. Didn’t work? use this Troubleshooter that doesn’t do anything useful. Didn’t work? I don’t know. maybe try refreshing your PC after all?

Eventually, I stumbled, almost by accident, on the solution. Many of the attempts were encountering an error about “The package repository is corrupted”. I found nothing addressing that except some statements about registry key permissions, which I checked and were fine. So I decided to find where this package repository was- C:\ProgramData\Microsoft\Windows\AppRepository- and nuke it completely. I deleted the entire contents of the folder, then ran the command again. I expected a different error or something, but that seems to have done the trick, and now those Apps all work again.

Effectively, the Windows Store/App stuff is something of a “Package Manager” and stores the package information in that folder. However it also has an index of the package information in a smaller repository file, and it seems that file can get corrupted. I tried deleting that as well but it never fixed it. I ended up going with the nuke-it-from-orbit option.

My full list of steps was:

Delete contents of C:\ProgramData\Microsoft\Windows\AppRepository
Deleted all the files inside this folder. Quite satisfying.

Ran an arbitrary non-obvious command from an administrator command prompt

Ran a final non-obvious program from the command prompt
After all this, other apps were still causing problems, like the useless Music app or the useless mail app or the various other useless apps that are provided and available. I’m not one to leave a hippo in vinegar, so I ran one more thing- I opened Windows Search and typed “wsreset” which brought up wsreset, then I right-clicked it and selected to run as administrator. After doing so, all the apps I had started working properly again.

I’d like to pause for a moment, however- to really admire how poorly engineered something has to be for almost any problem with it to declare that the user should try nuking everything and starting over. Microsoft calls it a “Windows Refresh” but it is a reinstall, and suggesting users reinstall an OS to fix these issues is absolutely ridiculous. Another very comical aspect to this is that in the “Windows versus Linux” argument, Windows diehards will complain that Linux requires arcane terminal commands to fix issues. Now, it’s hard to argue that- some issues in Linux distributions could require dropping to the terminal to fix issues with particular commands. But given the above- it doesn’t look like Windows is any stranger to that anymore.

One interesting trend I’ve noticed on tech-related blogs and articles is a strange focus on Linux- for example, “10 reasons to switch to Linux” or “Why I Switched to Linux”. These sorts of articles and posts are fine, but I’ve noticed a disturbing trend whereby the articles have such a strong bias that it practically dilutes the legitimate content of the article, and even removes any real value from it -turning it into nothing more than somebody typing 1000 words about nothing and based on nothing just to make a few bucks off the ad revenue.

Sort of like what I do here, except I don’t call myself a journalist.

Thing is, the problem with such articles on tech sites is they are coming from allegedly qualified individuals who should know what they are talking about, but they continue to repeat ridiculous fallacies about Operating Systems. There are a lot of real, actual benefits to using Linux but these posts and articles deluge you with idiotic reasons that in many cases aren’t even true.

The best way is to consider a specific example. Unfortunately I don’t want to give them the satisfaction of having ad revenue, so I’ll just take some central points that such articles almost always profess, and why I find them to be inaccurate.

“Windows always requires constant tweaks”

I Find this to be a curious argument, because in my experience, it has been the opposite. Even the most easy-to-use Linux OS will require a good level of scripting experience to use with the same level of customization as Windows; and you don’t get that functionality out of the base install in most cases. There is also the consideration of the script being compatible as well as upgrades. A specific case in my instance was that I wanted a wallpaper slideshow- sort of like Win7 has. The package manager of the distro I was using had about a dozen programs claiming this ability, but not a single one worked. Turned out I was using Gnome 3, and they were built with Gnome 2. I found one program (Drapes) which had a Gnome 3 plugin- that didn’t work as is, but I was able to find a freely distributed patch file for the plugin to fix it- that didn’t work either. After a few days if trying to get this basic capability in the Linux distribution I was running, I had about 2 dozen programs for switching wallpapers installed and had no idea which files they changed on installation- bash.rc had changes, and some of them installed background services. They had the common theme whereby they didn’t work, though.

I managed to piece a script together which I discussed here. I them realized my distro didn’t have sound notifications when I plugged or unplugged USB drives. I wrote another script to try to get that to work, but I either lost it or don’t have it. It was after this I realized that this held to me no real advantage over Windows; I could write a Windows Application to do all those same sorts of things if I needed too, but in fact the capabilities I was writing scripts for was built into the OS.

Therefore I find the argument that “Windows requires constant tweaks” to be a bit misleading. First off, almost any System is going to require software maintenance, and Linux is certainly no exception to this- you can’t just load up 30 different wallpaper change programs and have them fighting with your desktop manager by constantly interfering with one another. Additionally, I find that Linux requires more tweaks; this is it’s weakness but also it’s strength. The idea is that for such new capabilities and tweaks the person who creates it shares it with the world at large so other people seeking the same capabilities can simply use an existing solution. The problem is that this exact model works perfectly fine regardless of the Operating System anyway- and Other Operating Systems often have more solutions and tweaks of this nature- and often the tweaks and programs written for Linux are Desktop dependent or even package manager dependent.

“It’s Stress-free”

This is perhaps the most ill-informed sort of reasoning I’ve ever heard. It is far from stress free and to pretend that somehow a person switching from Windows will feel like they are prancing through an open flowery meadow of stress-free non-worry the moment they switch is anything but positive for the system being condoned. The only time Linux is “stress-free” would be after you have become very familiar with the system, but then you have just as many annoyances as you do when you are familiar with any system. It’s a sort of software infatuation, where you are so smitten with a system that you can see and possibly even elevate the positive attributes, while considerably downplaying real shortcomings the system may have.

“Linux is secure by design”

Every system ever designed has flaws, security problems, and exploits that can be used to get into those systems in the wild. Even FreeBSD, which has a meticulous security audit process, does not make you immune. As it currently stands the only reason Linux has any safety from maliciously-intentioned software is because there is no incentive to write malicious software that runs on Linux. If- as many people seem to want- Linux becomes a dominant Operating System, we will see serious exploits and malware being developed against and for that system and it will not be any different than the alleged “security nightmare” that Windows supposedly is.

“Fast And Gorgeous”

This is not a fallacy, though I find it to be rather irrelevant. It also depends on the distribution- if you want flash and pizazz you can get a distro suited for that taste; if you want something unassuming or simple, you can get that as well. One issue I find with much Linux software is that one thing that keeps getting done over and over again are desktop environments. It would be nice if there was more effort pooling being put into trying to make other environments better, rather than deciding to make a new one entirely.

There are a number of similar statements made in support of it, but one thing I find most disturbing is that a lot of the Linux appeal rides entirely on the waves of dissent for Windows; the people don’t really give a crap if the OS they are using is actually better than Windows- they just don’t want ot use Windows. That’s a fine reasoning on a personal basis but it’s a pretty damned crappy one at coming up with the actual Better System. At least FreeBSD and the other BSD communities don’t involve themselves in such idiotic slapfights, and instead focus on actually building good, usable software. It’s not perfect either- it can be tricky to install and there sometimes aren’t drivers or other software that you need, but the advantage is a lot more of the BSD is committed to making BSD better. They improve their systems over time, whereas a lot of Linux people just try to make Windows look worse.

Windows 8 has really sparked a movement in this regard- there are many people who, for whatever reason, have decided that somehow Windows 8 somehow goes beyond some imaginary line in their minds that Microsoft should not have dared cross. It is merely coincidence of course that this happens with every Windows Release ever– For example, 95’s release was the beginning of the end for Microsoft and people swore to never upgrade; Windows 98 was the beginning of the end for Microsoft, and people swore not to upgrade, Windows XP, Windows Vista, and even in many cases Windows 7. And now what we have pretty much the same thing. With Windows 95, people latched onto the Start menu and Windows 95’s evil way of organizing programs and it’s evil document-centric approach that was trying to do too much for the user, Users swore that they would never use Windows 95, that they would not stand this forced upgrade, and would stand firm with their copy of Windows 3.1. With Windows 98 people latched onto Active Desktop like bloodthirsty leeches, sucking it dry until they could no longer complain about it, and swore they would stick with Windows 95, which was obviously the last version made before some imagined downhill tumble… With Windows XP, people latched onto the default theme, saying it’s default theme’s colourfulness “fisher-price” was too playful for a serious OS, and they swore that they would stick with Windows 98- the last version of Windows released before Microsoft made the fatal mistake of abandoning the crappy ancient DOS-based codebase that was well-known for problems and instead decided to use their NT codebase which had already proven itself stable for the previous 8 years. “The fools” people said. “Why would they replace something that kinda sorta works most of the time with something that works all the time? And how will I run my 20 year old copy of Lotus 1-2-3? This is a forced upgrade!”, With Vista it was UAC. With Windows 7, it was how it hardly changed (more often people praised it for “fixing Vista” even though it practically changed none of the same problems people decried in Vista). With Windows 8, it is obviously the Modern UI that has been in the crosshairs of badly constructed arguments to ignorance. With each version, there were people who either swore to use the previous version, or swore off Windows and the evil Microsoft empire (The fact that people who had not really been a Microsoft Patron for years swearing off and boycotting Microsoft’s new products as if somehow that will hurt MS right then and there is a bit hilarious though).

IMO a lot of dissent with new systems- and this applies outside of Windows- to things such as Unity- is based simply on not being familiar with the new system. The interesting thing is that switching to Windows 8 from Windows 7 is going to be easier than switching to Linux, so I’m rather boggled at the logic, where Windows 8, by adding a new complementary user-interface model designed for providing a single development platform that can be used across various devices, has somehow ruined everything. People focus on Modern UI- usually referring to it as “Metro” because they have a case of recto-cranial inversion) and completely ignore pretty much every other aspect of the system- much of which is improved over previous versions, or entirely new.

Recently, Valve announced their upcoming ‘product’- a Free Operating System called SteamOS.

Steam OS is the culmination of a year or so of complete and utter cluelessness by Gabe Newell on Software products like Windows 8. Remember how he said that Windows 8 was a “catastrophe” and would be a “launch failure”? You might have expected him to change his tune when his very own Steam showed that 8% of Steam users were on Windows 8; whereas every non-Windows OS barely broke a single percentage point combined. He still stands by his ignorance. This ignorance included a completely misunderstanding of pretty much every single thing about Windows 8. His claims are that it is encouraging a closed gaming marketplace. It’s not. Desktop Applications still run. Desktop Applications still install; in fact you can even have installers to install Modern UI applications. Most games aren’t going to be using the WinRT APIs, though, so any and all argument about a “walled-garden” is entirely specious.

The problem is every “argument” against it starts with the postulation that you [i]want[/i] your games on the Windows Store. Why? That’s stupid. You can still use the same traditional digital distribution you do today. The Windows Store is only useful to you if you happen to have a WinRT Application that you would like to deploy to WinRT and Desktop platforms. Some simple games may fit this, but most games do not. And as a result, the argument about the Windows Store being closed is completely tangential. THhy argue that they need to actually have their Windows Store links point to another retailer. Well, my first question is why do they have a Windows Store link to begin with? Windows 7 doesn’t seem to suffer from the lack of a Windows Store and completely ignoring the fact that [i]the standard Desktop still exists in the Desktop versions of the OS[/i] I suspect is almost done entirely on purpose.

so, with the above out of the way, based on Gabe Newell’s various quotations on the subject, I can safely say that he has practically no understanding of Windows 8, the Windows Store, or any of those related technologies and his “concern” over it in regards to the gaming industry is based entirely on a castle of FUD he has built himself.

But to bring this circus act together, we have SteamOS. Apparently, SteamOS is Gabe’s answer to Windows 8; it’s more or less a crappy HTPC that runs some Valve Software and is based on Linux, and might be able to play almost 4% of Steam titles. Wow. Colour me impressed. I can totally get behind them working on this game company working on an [i]Operating System[/i] instead of actually starting any sort of development on the most anticipated game sequel ever. For somebody who throws their weight around in Gaming development circles they seem to be doing very little actual game development.

The fact that people are hailing Steam OS as some good thing that everybody in the gaming community needs makes me sick. Steam is still as awful a platform as it was ten years ago. The irony is that back then the complaints about a new closed gaming marketplace were directed at Steam. How can they throw those exact accusations at Microsoft when they very clearly are [i]running their own closed gaming marketplace[/i]? Steam decides if or if not a game get’s listed. That’s the very definition of a closed system.

With any luck Valve will either wisen up and get rid of the clearly incompetent Gabe Newell who has used his position almost either maliciously or stupidly for spreading idiotic FUD based on so little research the fact that he is still chiming the same old song and dance makes it difficult to consider him cognitively capable of being a circus clown, let alone running one of the biggest software distribution empires in existence today.

As many web developers are aware, there are a myriad of ways to develop websites and interactive web applications today. On the server side, one typically chooses from one of two technology stacks; the “Open Source” and the Microsoft. Disregarding political and license concerns, they really are very much equal in core capability. The Open Source stack typically consists of A Linux distribution as the Operating System, Apache as the Web Server, MySQL as the database, and PHP as the server-side language. These can also be installed to a Windows machine as well, and Apache has modules that even allow the use of .NET technologies via the Mono runtime. The Microsoft stack consists naturally of Windows as the OS, IIS as the webserver, and ASP as the core server-side script. ASP itself, of course, supports a number of languages; you can use JScript, VBScript, or a .NET language. Both of these platforms provide a myriad of tools at your disposal. LAMP allows you to leverage the wealth of Apache modules and use a large selection of programming languages like Ruby, Python, Perl, and of course PHP. The Microsoft Stack makes use of the very powerful SQL Server, and is particularly scalable to large operations. Of course there are variations of these; obviously MySQL could be swapped out for PostGreSQL, or even a remote SQL Server.

Costs

The cheapest hosting plans for most WebHosts use a Linux-based stack. This makes PHP one of the more accessible server-side languages to learn. When I started this sight, I wasn’t really sure how well it would turn out, what I would write about, or how much exposure it would give me or my various programs. After three years, I’m still not entirely sure of that; but at the time, I was working predominantly in Visual Basic 6. I was stagnating, and I didn’t even realize it. When starting the sight, I really had two choices- go with the Linux stack, or the Microsoft stack. My choice of the LAMP stack was done purely for a single reason: it was completely foreign to me. That may seem like an odd reason to choose a technology, but I’m always up to a challenge. I won’t try ot say that learning the “Linux way” of doing things was easy, but it did get easier over time. With the server itself of course I didn’t have full access anyway; just a standard CPanel, and I still do; but understanding Linux, Apache, and MySQL were very helpful in using PHP, which was the language I had to learn to get teh site off the ground beyond a few ugly static webpages.

I basically slogged through learning PHP, in an attempt to create a relatively simple CMS. After getting a basic CMS and some crappy side links started, I decided to redesign the site from scratch. I sketched how I wanted it to look on paper, and then set to work duplicating that appearance using the available web technologies, as well as through the use of Photoshop for the various images I needed. The end result is what you see on the main page; of course I’ve made changes to it since, and added features to the underlying CMS to support new functionality such as listing my youtube videos and different categories of items, but the visual appearance is much the same. I toyed recently with the idea of redesigning it, but decided that it could stay as it is now a little while longer; a redesign is a rather big undertaking, and I like how it looks now.

Since then, I’ve also learned and become quite adept (If I may say so) at C#. This has left me rather- annoyed- when I use PHP, which feels very messy in comparison to what is generally a very clean working environment. Not to mention being relegated to having to debug using echo, which I can’t say I really missed from using GW-BASIC.

I did install a MS Stack locally some time ago, and experiment with it for a short time before deciding to avoid it; I reasoned that if I was to use C# for web development start to avoid working on my PHP site even more. I’ve since changed my mind, however; I’ve decided to install a local IIS-based server and experiment some more with what .NET has to offer on the server-side. I’ve been able to make some pretty fine-looking stuff with WPF and Windows Forms, and I know WebForms as well as the Base-Class Library that is not heavily leveraged on the client side are one of the many areas where my abilities and knowledge can be expanded, so I can’t see why not.

Also, I’ve always thought it a bit weird that my site ran on PHP and I focussed mostly in Windows-based and MS technologies and languages. Though I don’t see a switch over occurring anytime soon.

Operator Overloading.

This was excluded from Java because it’s “Dangerous” or some other bullcrap. Just use the BigInteger class to see what a massive cock-up that decision was.

ref and out parameters

In Java, everything is passed by value. This cannot be changed. The hack to fix this for primitive types is to use one of those stupid boxing classes (Integer for int, Double for double, etc). The justification is that “all functions should only return one type” and that side effects are bad. But programming languages should provide as much capability as possible and sometimes you don’t give a flying fuck if the code is clean, you just want it to work, and having to rewrite some of your codebase because the designers of java decided to take out a few sharp edges is a pain in the ass.

Functions as first class objects.

Every method in C# is an object. you call the method if you add brackets and a parameter list; but if you don’t have brackets, you are referring to the MethodInfo object that represents that method. Methods can accept functions as parameters. Example:

Note also that this is using the => syntax to create a function on the fly. the function could have been defined separately:

1

2

//above function defined as int doublevalue(t original){return t*2;}

foreach(vartransformedresult inDoToAll(doublevalue,testarray))

What is Java’s Solution to this? Anonymous inner classes and interfaces. personally, I got sick of that with Visual Basic 6. Having to write a new interface to define a single callback method was aggravating and polluted the namespace. Java’s “solution” is anonymous inner classes, which is more a band-aid approach. Java apologists typically respond that “but this way it’s easier to add new methods”. But I don’t want a class. I want a bloody function.

Iterators. Heck that’s what I used above. Notice the yield return and IEnumerable<t> return type? that is quite literally impossible to do in Java. You can’t even fake it, certainly not in a transparent way, and not at all with java; you have to either fake it with some sort of goofy threading thing, which completely defeats the purpose of coroutines/iterators to begin with, which is to avoid the overhead of thread locking and kernel scheduling and be as light and fast as possible. Implementing them with full-on threads with tight restrictions gets rid of all the advantages.

A good case and point. In my game, I use an iterator to go through all the game objects. One of the side effects is that nowhere in that code am I “allowed” to change the collection being iterated over. My resolution involves a queue of delegates being stored as needed, and that queue is emptied at the start of each tick. One such usage is to add GameObjects to the list while that list is being processed:

//that item will be added at the start of the next frame when the gameproc empties the queue.

Can you do this in java? Well, you can fake it with inner classes and passing them around; and then giving it a field to hold that local variable, but what if you want to use other local variables? The above uses two locals- gcp and gstate. Local variables that are used in a lambda are closed over in the delegate and you can access them later. Literally this happens long after that method’s stack has been unwound; the variables that are closed over stay alive until the lambda itself is collected. The Java solution would need a new class that has a field for each “local” you want to use, as well as the logic of the function. What in C# takes a few characters of code in Java would take at least one new source file.

Properties. Oh dear gawd properties. Java’s been faking it for over 20 years with getX() and setX() methods, and that is utterly and completely disgusting. C# implements property support directly into the language. Properties can be on interfaces or abstract classes. They cannot be overriden in the latter case, but one can then define a protected set of virtual accessor methods for derived classes to override that the property routines use. Java’s solution is to let things “pretend” that the set/get accessor pattern is a solution. This property stuff get’s quite involved when we move into C# 4.0 along with XAML, where Dependency Properties provide a lot of notification functionality.

Which brings me to another- Events. Events in C# are defined using a name and a delegate that defines the event signature. Class consumers can then subscribe to that event- multiple consumers can in fact- using either methods of the event or operator overloads. The class can invoke the event and all the subscribed consumers will have their event routines called. This is known as a “multicast delegate” since it calls a number of methods on a single invocation. Java doesn’t have this. Again, the best way to fake events is the same way I used to do it with Visual Basic 6, which was to define an interface. that would allow for a Single “event” subscriber to be assigned, probably using some stupid “setEventX()” accessor. What if you want- you know, actual events with multiple subscribers. Well, thanks to Java’s weak generics implementation, you get to rewrite them for every single event, or use slow reflection to do your dirty work. Neither of which are exactly robust.

You want more? Extension methods. Linq uses these extensively over collection classes, providing a myriad of ways to mess about with them. How about the null coalescing operator ??, or the “as” operator for performing conversions between types and giving null rather than a InvalidCastException if it cannot do so?

Platform Invoke is better than JNI or whatever the fuck it’s called now in Java (JNI? J/Direct? damned if I remember). Of course the argument is that you shouldn’t have to use anything other than Java (or C#) to do something. But you do. That’s how the software ecosystem works. You can’t just hid in the Java sandbox and pretend nothing else exists, because then your UI looks like heap of crap and you end up with something whose features pale in comparison to other products and the only advantage is now you can run it on a Solaris without porting it or something.

Even the for(value:collection) foreach syntax in java was something that took years to get added to the language. The Creators hemmed and hawwed about it for years, as if they were making some life altering decision; because they had to make sure it wasn’t dangerous, right? I don’t even know the state of Closures in Java. Personally I gave up on the language after C# passed it with C# 2.0.

Java is a universally weaker language than C# that offers few real advantages, like comparing a companion cube to a edgeless safety cube, the only difference is that the user can’t hurt themselves. But an experienced programmer trying to stack edgeless safety cubes will find it very frustrating for the very reason that there are no corners.

When speaking of browsers, Operating Systems, or various other pieces of technology, people will often speak of “market share”. I’ve always found it somewhat puzzling; the term Market share implies that the various selections are mutually exclusive. The thing is though, that simply isn’t the case

Take Linux “market share” for example. I use windows, as my primary OS, but I also use Linux on my laptop. Where do I fall? Who’s Market share do I increment? I use firefox usually as my browser, but I have Chrome, Opera, and IE installed. Does having them installed count towards market share? And if not, how often do I have to use them before they “count”, and who decides that?
Basically, once people start bleating about market share, they’d lost grip with the facts. There is no “market share” anymore; it’s all about Mind Share.

Anyway that’s a quick post from me. In other news I’ve got some additions to my INIFile.cs class (including a fix) that should make a juicy entry,too.

Most Computer users are familiar with the Sounds that Windows emits when you plug and unplug a USB thumb drive. It’s a useful form of auditory feedback that the drive was in fact detected. However, I’ve found linux to be oddly tacit in this regard. So I set to work writing a python script that uses DBUS to monitor for new USB devices and will play a sound whenever a new Volume is attached.

Python

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

#!/usr/bin/python

#by BC_Programming

importdbus

importgobject

importtime

importsubprocess

print"BASeCamp 'USBSounds' Simple USB Volume notification sound."

#playsound merely shells out to mplayer. I would have preferred an integrated solution but... meh.

#note: I couldn't get DeviceRemoval sounds to work since it doesn't let you #inspect whether the removed device is a volume via "QueryCapability"... since it's gone.

def_filteradd(self,udi):

device_obj=self.bus.get_object('org.freedesktop.Hal',udi)

device=dbus.Interface(device_obj,'org.freedesktop.Hal.Device')

#if it is a volume, call the do_add function...

ifdevice.QueryCapability("volume"):

returnself.do_add(device)

def_filterremove(self,udi):

try:

#device_obj = self.bus.get_object('org.freedesktop.Hal',udi)

#device = dbus.Interface(device_obj,'org.freedesktop.Hal.Device')

#if device.QueryCapability("volume"):

# return self.do_remove(device)

except:

return

#unused....

defdo_remove(self,volume):

playsound("hardwareremove.wav")

#displays some info about the added device to the console (maybe future changes can pop stuff like volume label, device file, size, etc into a Notification box?)

defdo_add(self,volume):

device_file=volume.GetProperty("block.device")

label=volume.GetProperty("volume.label")

fstype=volume.GetProperty("volume.fstype")

mounted=volume.GetProperty("volume.is_mounted")

mount_point=volume.GetProperty("volume.mount_point")

try:

size=volume.GetProperty("volume.size")

except:

size=0

print"New storage device detected:"

print" device_file: %s"%device_file

print" label: %s"%label

print" fstype: %s"%fstype

ifmounted:

print" mount_point: %s"%mount_point

else:

print" not mounted"

print" size: %s (%.2fGB)"%(size,float(size)/1024**3)

#and play a sound.

playsound("hardwareinsert.wav")

#main loop...

if__name__=='__main__':

fromdbus.mainloop.glib importDBusGMainLoop

DBusGMainLoop(set_as_default=True)

loop=gobject.MainLoop()

print"in __main__..."

DeviceAddedListener()

loop.run()

As can be seen, it’s a tad messy, and even rather hackish. For one thing, it uses DBUS, which to my understanding is deprecated. Unfortunately, the replacement I couldn’t really get a clear answer on. From what I can gather, the proper method for now is libnotify and pynotify, but I couldn’t get libnotify to compile and thus was not able to properly use pynotify, and I didn’t want to have to force people to go through that sort of hell when they tried to use my script, so I stuck to DBUS.

The only limitation I discovered is that on device removal, you can’t really inspect what device was removed. At first I just figured, Just play the sound everytime and let the user figure it out, but for some reason that just assaulted me with constant device removal sounds. So I ended up commenting (and I think removing) that particular segment of code.

Playing Sounds is unnecessarily difficult in Python, or more specifically, Linux. It’s ridiculous. First I found a build in module for python, ossdevsound (or something to that effect), but attempts to use that failed because apparently it uses OSS, which apparently was replaced by ALSA for whatever reason. So I tried pygame, which errored out that I had no mixer device when I tried to initialize the mixer. So I decided to hell with it and just spawned a mplayer process, and redirected it’s stdout to NULL to avoid the nasty business where it barfs all over the console. And amazingly, that seems to work fine for device insertions, which I decided I was content with.

By default I use the Windows insertion and removal sound files. The removal sound isn’t actually used but I kept it in the g-zipped tar because I wanted to. Personally I usually just launch this in a terminal and then tuck it away on another desktop. No doubt one can execute it as a daemon or something instead and get the functionality without the console window baggage to keep around, though.

One feature of windows that I often miss while using My Linux laptop is the ability to eject USB drives from the system tray. With my Linux Mint 10 install (and likely newer versions, and of course other distros) you typically need to minimize everything to get to the desktop (or of course use the shortcut, but you still need to minimize everything) get to the icon, right click it, choose to eject it, etc. With windows, you simply Left-Click on the icon in the Notification area and click the drive to remove.

Thankfully, It turns out there is a very cool and unassuming little program that provides this exact functionality. It is called “ejecter”.

Without dwelling on the fact that it really ought to be called Ejector, the program does exactly what it says on the tin. When you plug in a USB drive, the icon appears on the system tray.

Ejecter's ejection tray flyout. Or menu.

As can probably be guessed, this is exactly the type of functionality I needed. You can see exactly what the product looks like in the image to the left; when you left-click the icon, a little tray pops out (some might call it a menu, I suppose) and lists the connected USB drives that can be “Safely removed”. I rather like how it shows the Volume name as well as the name of the device itself, which helps prevent confusion. Ejecting the device entails clicking the Eject button to the right of the device you want to eject. Two clicks and you’re done!

It’s very simple to install, to- it’s in the repository of most distros; usually it’s a quick sudo apt-get install ejecter or the equivalent command (I remember yum but not the syntax). It works on GNOME, but I’m not sure if it works with KDE, or any other Desktop environment, for that matter.

(I’m presuming the commenter here is the Mr.Bisquit from there, based on the second comment)

Yeah, You’re scared, especially when it comes that someone needs to search out an answer from you.

Scared of what? I didn’t post in that topic because it quickly devolved into you being a douche to anybody who posted:

7. A line is a set of points. (from the thread)

What is that? You know exactly what he meant, you were just being a giant douche, and the fact is by that point I realized that your question was probably just some sort of loaded trollbait in an attempt to allow yourself to express just how much of an elitist douche you were. Your additional responses that were designed to illicit a response from me “he’s afraid” afraid of what? what the hell is there to be afraid of!? That doesn’t even make any sense.

Actually- I think I know what that is reference to- the fact that I didn’t approve the first comment in the few days since the second was made. Actually, I only noticed the new pending comments today, when I went to write a new blog post. In that context, I do apologize for the delay, and can certainly understand the conclusion you came to (that I was maliciously censoring your comments) I wasn’t though, they are automatically moderated that way. I do have a question- if you ever return-

Why are you so fixated on me, anyways? I mean you posed a question specifically for me on CH and now you’re basically stalking me on my blog…. Why?

This is going to be much more difficult than it was to convince you to use a Linux distribution.

I was using GNU/Linux long before you were a known entity to me. You haven’t really convinced me of a whole lot, except that there is a hell of a lot of polarization and fanaticism on the xxxBSD side of the fence then I had original suspected. I mean, a good portion of Operating System/platform evangelists are self-righteous blowhards, but you have really raised the bar.

>>Makes me wonder about a programmer who mentions assembly
>>and C then clams up when it comes to “new” territory.

clams up? what the hell are you talking about? I didn’t respond to that particular thread because your question was clearly loaded, and second, because, as I noted here, I don’t have a “take” on it because I haven’t used it. I try to make a habit of not forming too strong of an opinion about something if I haven’t used it, but you aren’t making it very easy. I doubly wouldn’t know about running it on the specified hardware because I haven’t USED a PowerPC, nor a SPARC, and have barely even used FreeBSD on x86. I don’t have a powerPC. I don’t have a SPARC, and buying one or both kinds just because you’ve asked my opinion on running a specific OS on them would be pretty silly.

you use freeBSD. Good for you, really, I’m sure it’s a fine OS, clearly it suits your needs. I don’t use FreeBSD. Get over it. I already have it in a VM; I just haven’t done much after the initial install (like doing the appropriate googles to find out how to turn the basic # prompt with a relatively minimal set of commands into a usable desktop environment. But I will do it when I please. Some douchebag being- well, a insistent douchebag throwing not-so-subtle insults and insinuations my way is not going to help, because if that is what I’d be destined to become as a freeBSD user, I want no fucking part of it.

I suppose, as has been said frequently about many things, it’s not Free/OpenBSD I have a problem with, but some of it’s users. Same with Linux; hell, same with windows, or mac. It’s the evangelist assholes who seem to feel they have some sort of inner track to knowledge, that the OS they use is better, despite the fact that their measurement of what was better is using their own predefined yardstick that just happens to only cover the strong points of what they are evangelizing. They also all have a glaring weakness. You tell them a problem with their OS of choice, and they say it’s your fault. This isn’t specific to any OS at all of course. The fact is though, they all have problems. Evangelists of all kinds seem to think that pretending there aren’t any problems- or that those problems are minor- is a good thing. It’s not.

For example, as it stands now- you simply NEED to learn how to use BASH or whatever the included shell is with almost any Linux distro and with all the BSD’s I’ve tried; for the “simpler” Linux’s, like Ubuntu or Mint, people will often still need to use to the console to fix otherwise simple issues- like the package manager somehow getting into some weird inconsistent state and refusing to open; sure, it suggests what command needs to be issued, but in that case there are two problems:

why can’t the GUI program invoke the suggested command itself?

The command doesn’t always work

For ages, running that command on my laptop would effectively hang that terminal until I forced it closed. Now this brings me to another point; I ended up just using the –help of the various package management tools (dpkg, apt-get) and found that apt-get had a “check” option, and was able to invoke that and discover that one of my python libraries was corrupt (or, “inconsistent” I guess), I then (using more inference) decided to simply remove, and then reinstall that package, which fixed my package manager issues. hurrah!

I’m not saying that was bad by any stretch, but implying that everybody is willing to go through that to get their computer working properly is utter nonsense. Some people think their computer is broken when the desktop background is wrong and they don’t know how to change it. Yes, they can learn how to change it, but the thing is, a lot of people don’t give a flying fuck about computers. This is something we more nerdy types, regardless of occupation, seem to forget. If Secretaries had the capability to learn about stuff like the command line, they wouldn’t be secretaries.

Basically, the adeptitude that many Linux and FreeBSD versions demand of their users is akin to demanding that everybody learn the specifics of architecture, wiring, roofing, insulation, beam installation, and so forth when they buy a house. Now, it’s true, that a fair number of people that purchase a home do in fact fix it themselves, and no doubt learn in the process; but there are others, who, again- are either too busy or simply don’t give a fuck and hire people to do it. They don’t want to learn about plumbing or wiring or roofing. They just want a house, just as some people don’t want to learn about files, streams, ports, hardware ports and Addresses, IRQs, DMAs, NMI’s, Compilers, command lines, or the details of memory. They just want a computer. Now, some on “the other side of the fence” from them, (including myself) may balk at such a concept “An easy to use computer, how absurd!” After all, in many ways the very “general purpose”-ness of a computer simply doesn’t lend itself to being “easy to use”; but it seems that should be what we are striving for. No Operating System ever created meets this lofty goal of being completely intuitive. My opinion in that context is that Mac Classic (Pre OSX, that is) was the closest to that. And, really, creating a completely intuitive interface is thought impossible; that doesn’t mean we should just give up on it. There are people in this world who aren’t interested in computers; They don’t want to have to learn arcane commands to get their shit done. They just want to get their shit done. They don’t want to have to learn how to write a script to automate that task. This is not something that should be shrugged off as “well obviously they are an idiot” because get this, Computer’s aren’t the fucking world, even though the world seems to run on computers,and almost any occupation will involving interfacing with computers in some way or another. what we need is some fucking work on making those interfaces easy to use. not just flexible. In that sense, my “Take” on FreeBSD, which you’ve forced out of me through sheer willpower apparently, despite my misgivings that I haven’t even really tried it much, is that it makes absolutely no attempt to be easy to use and trades off at every point better flexibility and security for ease of use. The security concern is understandable, but if you are going to make something flexible, either make it flexible and easy to use, don’t attempt to call it a mainstream OS for everyday people, or don’t bother.

EDIT 2:

Welcome back 😀

Why can’t the GUI application post the command?

1) All options are not available on the GUI but are available on the command line. The GUI is merely a front end to a command.
2) Every person that develops such an application is not aware of all of the options.
3.) Every command is not possible in every situation.
4) It may be assumed by the developer that the individual wants some control.

Specifically, I was speaking for the case of the Synaptic Package manager, which complains when started occasionally and suggests that the user run “dpkg –configure -a” Basically, why does it have to do this- could it not run that command itself? It basically acts as a front end for dpkg, from what I can tell. But, when it is suggesting to run that command- why can’t it do it? The only reason I’ve found for it is that it only fixes the problem 90% of the time, the other 10% of the time you have to figure it out yourself, all the while having the package manager suggest you run that same command each time it doesn’t work. The people developing it are clearly aware of the options they suggest, because they are- well, suggesting it. Response 3 makes sense in the more general case, but I was speaking (specifically) about the dpkg error from the package manager that basically told the user to run a given command to try to fix it- the thing is, the problem can be resolved entirely programmatically without user intervention- just by shelling out and performing two dpkg commands. #4 is a moot point, really- performing the tasks you are using the GUI to do manually defeats the purpose of said GUI. If a user wanted “more control”, they probably wouldn’t be using the GUI tool to begin with.

The choice of shell is up to the individual. In any Unix-like environment, one needs to know the command and its options.

But Why? Why do you need to know commands and their options to use the relevant GUI tool? Isn’t the point of the GUI tool to make it so you don’t have to use the command itself?

Shell programming is useless if you do not understand what you are doing.

Of course it is. I never say anything about shell programming though…

Nobody is fixated on you.

And yet, here you are, again.

A question was asked on one site and the answer was given on another.

The answer was given on another because by the time I saw the thread it had already turned into you saying it was “an open public challenge” or some other nonsense like that. A open challenge to… do what? At that point I felt it was some sort of flamebait or something so I didn’t bother to post there, also, because I didn’t really have an answer since I don’t have any non x86/x64 systems. The idea that asking somebodies opinion on something was a “challenge” still irked me though, so I posted this entry. (because by that time, the thread in question had been locked), if the thread was still open at the time I probably would have put this there instead. (in retrospect I probably could have created yet another thread).

It would have been easier and more direct to give the answer of “It doesn’t interest me at this time,” and have it end at that.

And what obligation am I under to answer any questions at all? None. And the I got from the thread that you seemed to feel I owed you something was another reason I abstained from posting at the time. I may very well have misread you in that instance.

.NET; I might have ranted about this before, if not on my blog, elsewhere. most of my arguments were against it, being a VB6 using ignorant buffoon. In any case, I’ve found C# to be an awesome language. One of the obvious downsides is that for the most part programs written in C# using Windows forms cannot be run on other systems.

The concept of Mono is to change that; remember, C# isn’t a Microsoft standard, it’s an ECMA specification, and Microsoft holds no copyright over it or anything like that. Mono is a relatively huge undertaking; the creation of something on the scale of a Virtual machine as well as a class library is gargantuan, and of course there is very little hope for 100% success.

On the whole, Mono performs it’s primary goals admirably; there is a GTK# framework that can be used to develop windowed applications… of course then the installation on a windows PC would require the install of the Mono GTK# framework, but I digress. In any case, applications can be developed and the C# code interpreter (for on the fly syntax highlighting) as well as the compiler are top-notch and seem to work well.

My only beefs can of course be in the class library. Of course, re-implementing the class library provided by MS on non-windows systems is not something that can be done in a single afternoon; this stuff takes time. My attempts to create a Mono-compatible project have been stifled, however, by seemingly innocuous issues. AlLlow me to explain.

As many reader may be aware, I have been working on a “upgrade” of sorts to my now ancient “Poing” game, which can be found on my downloads page; the original game was written in Visual Basic 6, and, in it’s earlier incantations didn’t have a single Class; it was all based on User-Defined Types (structures for those privvy to C parlance) and functions; (short explanation: it was made before I understood classes). Later, after I had learned about classes, I refactored everything into classes. This is all rather redundant; in any case, I have since created a new project in C#, in an attempt to learn about GDI+ as well as what appeared to be a different (in some ways) painting model. As one can see by the youtube videos I have posted on it, development has gone well.

The idea occured to me, after Tux2 (of http://www.jrtechsupport.com/) managed to create a Mono-workable, if soundless, version of my earlier C# game, BCDodger that worked in Linux. Sound was unavailable as a result of my choice of sound library, the IRRKLANG library, while truly usable in Linux, doesn’t have a wrapper that works in Linux (or something, I don’t know… it uses DSound or something, I forget). In any case, I have since added the ability for various sound engines to be used, and have added working implementations for Open-Source and Linux-available Sound systems, such as NBass (as well as a broken fmod implementation, let’s ignore that though).

Much obliged, I had decided to try to get it working via Mono as well; this was facilitated by my recent reformatting of my laptop to run a dual boot Windows 7 and Mint 10 system. Installing MonoDevelop and all that, etc.

So, I of course open the project in Monodevelop, quite ready for errors relating to porting.

The version I am using is MonoDevelop (and I assume also Mono) version 2.4, for those following along.

My first hurdle was getting my Appdata files for the program in the right location; on windows systems they are placed in the application data folder; so too they would need to be on a Linux system. Thankfully, a quick C# program run on the Linux machine cured this issue:

Nothing particularly out of the ordinary there. So, running the program on a Linux machine:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

Programs=

Personal=/home/bc_programming

Personal=/home/bc_programming

Favorites=

Startup=

Recent=

SendTo=

StartMenu=

MyMusic=/home/bc_programming/Music

DesktopDirectory=/home/bc_programming/Desktop

MyComputer=

Templates=

ApplicationData=/home/bc_programming/.config

LocalApplicationData=/home/bc_programming/.local/share

InternetCache=

Cookies=

History=

CommonApplicationData=/usr/share

System=

ProgramFiles=

MyPictures=/home/bc_programming/Pictures

CommonProgramFiles=

which gave me what I needed: the appdata folder “BASeBlocks” needed to be copied to /home/bc_programming/.config.

Doing so was easy enough; the file manager on Mint 10 (dolphin) is different from windows explorer but hardly paradigm-breaking.

That copied, I simply threw the source folder as it was on the Visual Studio 2008 projects folder into the MonoDevelop projects folder (well, not really, it was /home/bc_programming/projects/ which I suppose means that any program that uses a projects folder will use it, oh well.)

psyched as I was I ripped into it with MonoDevelop, ready for anything! well, nearly anything.

My first error occured on line 107 of “Block.cs”:

1

mPowerupChanceSum=Powerupchance.Sum();

Java programmers may be thinking “ew uppercase characters” to them I say be quiet you. Anyways, the problem here was that there was no “Sum()” Extension method defined. Which I found odd. Oh well, though, I simply created my own:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

#if MONO

publicstaticclassmonoextensions

{

publicstaticfloatSum(thisfloat[]floats)

{

floataccumulator=0;

foreach(floatloopfloat infloats)

accumulator+=loopfloat;

returnaccumulator;

}

}

#endif

this solved the immediate issue of the “Sum()” extension method. (For more info on C# extension methods, see here)

My next hurdle was on line 540 of cBall.cs:

1

if(wholeref.Blocks.Count((q)=>q.MustDestroy())==0)

The error was something to the effect of not being able to pass a delegate or method group to a lambda expression.

oddly enough, the fix was the change the “q” to an x… and after it successfully built I was able to comment out the “new” line (with the x rather then a q) and uncomment the original. very odd.

In either case, now I was confronted with what I knew to be the biggest issue; the fact that I had to now discover how to set it up so that I was able to use the same nBASS library, but so that the nBASS library was “silently” made to use the BASS.so linux library, rather then bass.dll which wouldn’t load either way.

The first step in this process was in finding bass.so. Hoping for the best, I pulled up good ol’ synaptic package manager.

No luck there 🙁 so, I went into the depths of the internet….

the BASS for Linux (note the lack of the n prefix; it’s the core BASS library that the nBASS dll is wrapping) can be found here

So, I downloaded the zip file, extracted it to a folder, and am about to attempt to compile it. (there is a libbass.so that I could probably try, but I think I’ll compile it myself instead).

Before I continue, however, I would like to mention something that has most impressed me about Mint 10; the multiple desktops. Now, this is hardly a new feature; programs can be downloaded that do this on windows, and windows itself has built in API support for multiple desktops; however, what impresses me most is that when you activate a window on another screen, it switches to it; what I mean is, for example, in this instance my FF download window was on another desktop (no idea why) and when I went to open the downloads window via Tools->Downloads, it did the fancy compiz box animation (as I have selected in preferences) and switched to it. very cool. But enough if my gushing over the unexpected presense of sanity in the UI design of a Linux desktop environment! back to my attempts to get BaseBlock working on Linux.

Oh the humanity! now I had to learn about this package nonsense. I first suspected perhaps, as evidence by the fact that it wasn’t found, said package wasn’t installed; so I did a quick sudo apt-get install libglade-2.0 … it reported it was installed already.

after a bit of effort, and installing a few dev packages, I gave up. I was able to resolve the missing dependencies but then it complained about a missing .h file (which was indeed missing and clearly should have been present) so I gave up on that, and am at the time currently trying to simply use the .so file included. An additionally problem that arises here is the obvious fact that I am using a x64 Linux system, working with C# code written on a x64 windows system but targeted towards a x86 system, problem being that to my understanding Linux is not as lenient when it comes to architecture differences; but I suppose I’ll figure that out for myself if it’s the case.

In any case, I am now attempting to get the nBASS library to wrapp around libbass.so rather then bass.dll; from my research if the imports are the same I should have no problem creating a dllmap entry in the appropriate config file. From the documentation it would seem that discovering where that config file goes is left as an exercise for the reader.

Actions:

pasted libbass.so in the “Debug” folder (alongside the dll).

Copied the BASeBlock.config file from the project root to the debug folder; renamed to Bass.Net.config.

opened preceding file in gedit; it now looks like this:

1

2

3

4

<?xml version="1.0"encoding="utf-8"?>

<configuration>

<dllmap dll="bass.dll"target="libbass.so"/>

</configuration>

And now, I attempt to run BASeBlock… recall that it now compiles on Linux, so it’s just a matter of making it work. I could, in a worst case scenario, construct a “nullsound” driver that simply stubs out the sound playing interfaces. But that seems like a bit of a cop-out. IN any case, attempts to run it resulted in the same error; clearly either the documentation I was reading was incorrect or I was not interpreting it properly.

I did a few more googles and came upon this page, which, despite being about something completely different addressed the same problem; that is, translating the dllimport(whatever.dll) into imports of functions from Linux .so libraries. namely, it told me where the Mono parameter file was- /etc/mono/config. I quickly opened the feller using gedit:

I tossed in the line:

1

<dllmap dll="bass.dll"target="libbass.so"os="!windows"/>

and crossed my fingers…

It still didn’t work. I guessed maybe mono only loaded that stuff up when it was started? So I restarted monodevelop.

excellent! a little progress. Now I was still getting the error, but it was complaining about libbass.so missing. At least we’re getting somewhere.

It still should have found the file; however, I decided that instead of just throwing it in the app directory (because god knows where Mono is truly looking for it; even putting ./libbass.so in the dllmap failed, so Mono clearly thinks something else is the “current” directory. Instead, I decided to simply cp it somewhere globally accessible;

It still didn’t work.

Anyway, I messed around with the config file and the dllmap attribute and no matter what I put it it refused to find the file; clearly I’m missing something obvious (maybe capitalization? a missing slash? who knows). In either case I decided to defer that work to later on; I’m sure there was more to be fixed afterwards.

So, I created the aforementioned “Null Sound” driver; it worked fine. compiled alright. Encountered a bunch of issues during startup relating to my use of the \ as a path separator, whereas Linux uses /, fixed this with a simple Replace to change all slashes to the slashes of the OS (Environment.PathSeparatorChar).

It still refuses to start; Some gdi plus error. I have no idea how to workaround this, since it seems to be related to the windows forms, and has nothing to do with my own code, but rather with some configuration option. I recall Tux2 working around a similar error in BCDodger but I wasn’t paying very close attention and forget what the fix was, or even if he mentioned it. Either way, at least now BASeBlock compiles on a linux system, and most of the code-related oversights have been resolved.

EDIT:

I’ve managed to solve both issues; not at once of course.

First, the loading issue was fixed; pretty troublesome. In my attempts to resolve the problem I created a number of projects that used the same Image.FromFile() method to load pictures, and they worked fine.

Clearly, the problem then was not in what was not visible; the difference between the two. I realized that the difference was pretty clear: in my test projects, I was loading the images from within the form’s Load event; in BASeBlock, they were being loaded in a static constructor. So I decided to try to load the images elsewhere; I converted the static constructor to a static function, and called that function in the form load; there were a few other changes that I needed to make, mostly in the form of initializers attempting to use values that wouldn’t have been initialized.

The game started and ran fine with the NullSound driver.

Now, to fix the Sound; I opted to try to get nBASS working.

the solution was actually quite simple; merely a dllmap for bass.dll to libbass.so, and placing the x64 libbass.so in usr/lib was enough, and sound worked fine.

Unfortunately, it’s still slow as hell but at least I think that’s Mono’s fault.