Wednesday, May 12, 2021

Autohotkey, mouse button different action, click vs hold

;// This is the "back" button ...
;// Keywait waits max 210ms for key release. 
;// IF: (keywait < 200ms) -> send the actual button, IF: (keywait > 200ms (or timeout)) -> send key PageUp.
XButton1::
    x:=A_TickCount
    Keywait XButton1, T0.21
    d:=(A_TickCount-x)
    If (d<200)
        Send {XButton1}
    Else
        Send {PgUp}
Return

;// This is the "forward"-button ...
;// Keywait waits max 210ms for key release.
;// IF: (keywait < 200ms) -> send the actual button, IF: (keywait > 200ms (or timeout)) -> press the 1-button down, repeat.
XButton2::
    x:=A_TickCount
    Keywait XButton2, T0.21
    d:=(A_TickCount-x)
    If (d<200)
        Send {Xbutton2}
    Else
        Send {1 Down}
Return

;// When "forward" is released, the 1-button is released ...
XButton2 Up::
    Send {1 Up}
Return

Friday, May 24, 2019

Youtube video pop-out with autoplay and in HD!

I like to have the youtubes in a little popped out window next to my main browser in order to keep it visible when doing other stuff.
This greesemonkey/scriptish script replaces all the video links on the youtube site with a javacript window.open call which, predictably opens a new window with the video in it.

Saturday, November 24, 2018

"Keep WiFi on during sleep" from adb

adb shell settings put global wifi_sleep_policy 2
* Always = 2
* Only When Plugged In = 1
* Never = 0

Sunday, October 14, 2018

Backup running VirtualBox machine (with only a tiny interupt)!

There is a lot to be said about backups. I won't even try to cover all bases. I'll just show you what I'm using, that works for me. Yes.

In a nutshel this is what happens
  • some sanity checks and destination creation.
  • copy xml-config for chosen VM.
  • create snapshot for chosen VM so that original vdi-file is released.
    • will pause running VM for 1-2s. There is a --live switch for the snapshot command but I have not tested this.
  • copy original vdi-file to backup destination.
  • remove snapshot thus "merging" the changes back into the running vdi.
  • ???
  • profit!

Input is name of VM-machine and index of backup.
Output is a backup of your machine ... who'da thunk it.

The usage of rsync is mostly cause of access to --progress but this could be substituted for simple "cp" or similar.

Update 1: Now using --live switch for the snapshot command. Without it one guest with USB attached kept getting Aborted when snapshot was taken. With --live it's working again.
Update 2: The --live switch was not the issue :(. Apparently snapshots does not work with anything lower than the USB 3.0 controller. This controller does however lose the attached devices when you snapshot the guest instead. Bah. Workaround is a detach and re-attach of the device to the affected guest. In my case this is not a problem but if you are attaching a disk drive or something that the guest is using constantly this might lead to bad stuff. Take care.
Update 3: So the UUID changes with every boot and every physical reattach of the device, how very practical. Well, let's fix that.

That's it. It works for me, ymmw. :)

Tuesday, May 29, 2018

Create random Spotify playlist with bash, curl and the Spotify API

Untinkered with this script will
  • add 140 random songs from the source-playlist(s) to the destination-playlist
  • keep track of added files
  • keep artist-separation at 50 songs (some songs "featuring" other artists might slip through)
  • filter out titles with "bad" words, "live in", "live at", "remix", "shitty version" ... etc.
  • filter out artists
  • filter out songs by id

You need a access-token with enough permissions (scopes) to modify playlists. I created one with AAAALL the scopes for my personal use so I'm not entirely sure which ones are really needed.

On to the script ...

Sunday, October 30, 2016

Kodi addon, run script on playback action

Addon version of a kodi-script I never published here ... so yeah.

Run scripts when you start playing a video in kodi. In my case I turn off some HUE-lights on play and turn them on, in red, on pause.

2021-03-14: Made this a bit less shit, maybe. Added some debug-logging. Also in a sort of "auto-like" for youtube-videos, very hacky.

Monday, June 27, 2016

Spotify: Remove Recommended Songs in playlists

1. Navigate to: %userprofile%\AppData\Roaming\Spotify\Apps
2. Rename the file playlist-desktop.spa to .zip and extract it to .\playlist-desktop then rename it to .bak.
3. Edit .\playlist-desktop\css\style.css and change the rule for .playlist-extender-content to the following:
.playlist-extender-content {
  display: none !important;
  margin-top: 60px;
  margin-bottom: 16px;
}
4. Restart/start Spotify and enjoy a Recommendation-free experience. \o/

Saturday, February 27, 2016

Firefox - userchrome.css, the 1px border-annoyance ...

At the bottom of the navigation pane at the top of the firefox window, there's a colored border. This border is not in fact, as one probably would guess, a border at all. It's an ::after-thingy with a height of 1 pixel. I don't know the reasoning behind this but I gonna call it stupid regardless. And if not stupid, at least unnecessary and unusual. Borders do their job, why complicate it?!

Ah well, it's gone now ...
#navigator-toolbox::after {
  /* srslyfuckyoumoz */
  height: 0;
}

Saturday, May 16, 2015

Home "automation" in Linux with netcat/socat

I realize that this post i lacking in instructions. I might flesh this out at a later date but no guaranties. It's not really that difficult once you figure out my madness ;)

I'm using tasker and udp sender to send udp packets with commands to a listening socat.

So if I send, for example (trailing blank line is intentional):
hue_on
kodi_on

my Hue lights and HTPC will turn on. Tasker is then set up to send these commands when my phone connects to my home network. Simple and effective.

On to the script.

Saturday, April 25, 2015

Monitor/screen standby on Raspberry Pi 2

These instructions are kind of hastily thrown together so you might want to research this on your own a bit more and not simply copy-paste this.

We will use xscreensaver (from the repos) and tvservice - which is (apparently) preinstalled in /opt/vc/bin/tvservice - to control the video output and turn the connected monitor on and off.