PowerShell script to generate a Rainmeter skin

I recently discovered Rainmeter, a desktop customization tool that lets you use some really nice looking gadgets. I wanted a simple skin to show disk free space.

rainmeterskin

I have five volumes, I could have manually written a custom skin. (Rainmeter skins are INI files.) That would involve setting a measure section for each disk and a in another section define how the output looks. Or I could take the much more time consuming task of writing a PowerShell script to iterate through my disks and write the skin INI file.

Download RainmeterDisksSkin.ZIP

The body of the script:

# Stop on the first error
$ErrorActionPreference = "Stop"

$RainmeterPath = [environment]::getfolderpath("mydocuments") + "\Rainmeter\Skins\"
$SkinName = "Kenward"
$FileName = "disks.ini"

If (-Not (Test-Path $($RainmeterPath + $SkinName))) {
    Set-Location $RainmeterPath
    mkdir $SkinName
    }

$OutFile = $RainmeterPath + $SkinName + "\" + $FileName
$Disks = Get-Volume | where {$_.DriveType -eq "Fixed"} | sort -Property DriveLetter
$Disks

$Header = @"
[Rainmeter]
Update=1000

[Variables]
vFontName=Segoe UI Light
vFontColor=255,255,255,255
vSolidColor=0,0,0,128
vFontSize=14
vStringCase=Lower
"@

$MeterCommon = @"
`n[MeterDriveInfo]
NumOfDecimals=0
FontFace=#vFontName#
FontSize=#vFontSize#
Meter=String
X=0
Y=0
FontColor=#vFontColor#
SolidColor=#vSolidColor#
AntiAlias=1
AutoScale=1
StringCase=#vStringCase#
"@

Out-File -FilePath $Outfile -InputObject $Header

foreach ($Disk in $Disks) {
    Out-File -FilePath $Outfile -Append -InputObject "`n[MeasureFreeDiskSpace$($Disk.DriveLetter)]"
    Out-File -FilePath $Outfile -Append -InputObject "Measure=FreeDiskSpace"
    Out-File -FilePath $Outfile -Append -InputObject "Drive=$($Disk.DriveLetter):"
    Out-File -FilePath $Outfile -Append -InputObject "UpdateDivider=5"
    }

Out-File -FilePath $Outfile -Append -InputObject $MeterCommon

for ($i = 0; $i -le $Disks.count - 1; $i++)
    { 
    if ($i -eq 0) {
        $Output = "MeasureName=MeasureFreeDiskSpace$($Disks[$i].DriveLetter)"
        $TextValue = "text = ""$($Disks[$i].DriveLetter) drive %1B free"
        }
        else {
            $Output = "MeasureName$($i+1)=MeasureFreeDiskSpace$($Disks[$i].DriveLetter)"
            $TextValue += "#crlf#$($Disks[$i].DriveLetter) drive %$($i + 1)B free"
        }
    Out-File -FilePath $Outfile -Append -InputObject $Output
    }

Out-File -FilePath $Outfile -Append -InputObject $($TextValue + '"')

PowerShell and the Registry, a Quick Start

It’s very easy to access the registry in PowerShell. Usually you will want to read or write to the registry. These examples show how.

The registry key in these examples is “HKLM:\SOFTWARE\MyAwesomeKey“.

Suppose I wanted to read the data from a value called “Kenward”, into a variable. I would use this command:

$myvalue = (Get-ItemProperty -Path HKLM:\SOFTWARE\MyAwesomeKey).Kenward

Easy huh?

If you want to write to the registry, it’s also very easy, for example:

Set-ItemProperty -Path HKLM:\SOFTWARE\MyAwesomeKey -Name "Kenward" -Value "somevalue"

PowerShell is smart enough to know that you are writing a string to the registry, so that it automatically makes the value type a string (“REG_SZ”) in the registry.

If you write a number to the registry, like this:

Set-ItemProperty -Path HKLM:\SOFTWARE\MyAwesomeKey -Name "Meaning" -Value 42

It will make the value of type “REG_DWORD”, a 32 bit number.

If for some reason you need to force the value type to be a certain type, you can use the -type parameter of Set-ItemProperty to specify Binary, Dword, ExpandStrind, MultiString, None, Qword (64 bit number), String, or Unknown.

That’s it! Let me know if you have any questions.

Thick and Thin, Eager and Lazy: vSphere Disk Provisioning types

When adding disks to a VM in vSphere you may have seen “Disk Provisioning type” and wondered what the benefits of each type were. Disk performance and disk space used are what governs the decision to use each type.

The 3 disk provisioning types are “Thick Provision Lazy Zeroed”, “Thick Provision Eager Zeroed”, “Thin Provision”. The things I want to explain are the difference between “thick” and “thin” disk and the difference between “eager” and “lazy” zeroing.

Continue reading “Thick and Thin, Eager and Lazy: vSphere Disk Provisioning types”

8 Track Pi

8trackPiI’ve repurposed an 8 track tape into a case for my Raspberry Pi. Perfect for my XBMC Pi.

If you are doing this yourself, a few notes. The tape shell is in two parts. Try to find one that is clipped together rather then fused.  Look at the holes on the bottom of the tape to see what I mean. I had to dremal out some interior pins to make room for the Pi. Also had to cut a small hole in the side for the power. Please be careful!

Anyway, I love the juxtaposition of an ethernet cable going into an 8 track tape.

Creating music on Android

Lately, I’ve been looking into music composition apps on the Android. I’ve found a few that I like. Electrum is a straight-forward drum machine. I like that it is very similar to typical drum machine programming, so if you are familiar with that, then it will be easy to pick up. It comes with some built-in drum sounds, lets you download some, or add your own. Reactable (see screenshot to the left) is a fairly experimental composition tool High learning curve. You connect samplers, loops, sequencers, delay effects, etc, to make music. I can see making decent electronic music with this, but I’m still learning. I’m also experimenting with NodeBeat (fun and easy to use but creatively limited) and SPC (looks like a loop sequencer mostly but I haven’t spent much time with this one). I’ll probably write more on these later after I’ve had a chance to use them some more. Maybe even post some MP3s.

Fix Android “Low on space” message

I finally found a fix. I’ve been getting the “Low on space – phone storage space is getting low” message on my HTC Incredible often. I get this message even when I have hundreds of MB free. I’ve tried ignoring the message (no other problems really come up). I’ve tried deleting applications– that sometimes works, sometimes doesn’t. I think I’ve figured out what it is. The fix isn’t permanent, but it does clear the message.

Please read and understand the whole thing if you plan to do what I’ve done below. It’s involves deleting data– you may lose important information.

Continue reading “Fix Android “Low on space” message”