Skip to content

Instantly share code, notes, and snippets.

Notes about setting up PopOS 21.04 on a Lenovo Thinkpad Yoga 460

Including touchpad, touchscreen, dock, external screen, trackball. Mostly for my reference, but might be useful for others on same or similar laptops or OSes. Coming from Windows 10 + Chrome

Configure trackball

Logitech Trackman Marble trackball. Left small button to be a middle click when clicked once, scroll modifier when held.
Right small button -> back button, Left small button -> middle-click. Run the following to create a shell script that sets the right settings, then add this to the "Startup Applications" in the desktop manager. (Could not reliably get this working using .xinitrc, .xprofile or xorg.conf but running the xinput settings after desktop login works reliably). Note - this doesn't work after disconnecting/reconnecting - might need to add a trigger to run this on a USB connect event.

cat <<EOT >> ~/startup_commands.sh
#!/bin/sh
@askvictor
askvictor / cam.py
Created November 4, 2020 08:44
Flask script for a video ringbuffer for raspberry pi camera; HTTP trigger to dump the buffer contents (last x seconds) to disk.
import subprocess
from flask import Flask
import signal
from time import sleep
from datetime import datetime
vidproc = None
def start():
cmd = "raspivid -c -o out.h264 -s -t 120000 -fps 30 -rot 180 -w 1920 -h 1080 -b 15000000"
@askvictor
askvictor / README.md
Created January 26, 2019 05:50
SCRIPT-8
#!/usr/bin/env python3
import pychromecast
import threading
import cec
import time
# Configurable options
TIMEOUT = 300 # timeout in seconds
CEC_DEV_ADDRS = [5] # the device addresses of the devices you want to power off
@askvictor
askvictor / upload-and-verify.ps1
Last active March 2, 2017 04:05
Upload a file to Google Drive, and verify that it succeeded. Useful for backups.
# first use setup: run:
# gdrive-windows-x64.exe --config C:\programdata\GDrive about
# in order to setup auth token
# usage: backup-to-drive.ps1 -file backup_file [-delete_file] [-folder_id FOLDER_ID]
# -delete-file switch will delete the local copy once uploaded and verified
# -folder_id FOLDER_ID will upload to a specific folder on Google Drive (specify the ID from the URL of the folder)
# -email_server, -email_from and -email_to can be specified for notifications, or hard-code them here.
# if backup_file is a folder, then it will upload all items within that folder (and delete all of them if specified)
@askvictor
askvictor / mousescroll.ahk
Last active February 20, 2020 20:54
AHK script to do middle-click scrolling
#commentflag // ; Change to C++ comment style
// Code stolen from http://superuser.com/questions/1029053/autohotkey-scrolling-middle-click-mouse-acceleration/1029054
// Thanks to http://superuser.com/users/276424/user21820 for writing this
// Licence: CC-BY-SA as per StackExchange code licence prior to Feb 2016.
// Settings //
global rightbuttonscroll:=0 // set to 1 iff the right button is to be used for scrolling instead of the middle button
global scrollbeforeclick:=1 // set to 1 iff scrolling is allowed before the original button click otherwise scrolling is delayed for (clicklimit)
global leftrighttomiddle:=0 // set to 1 iff rightbuttonscroll==1 and pressing both left+right buttons together generates middle button press
use strict;
use warnings;
my $data = search("radiohead");
print "$data\n";
print "$data->{song_hits}\n";
print "$data->{song_hits}[0]\n";
for my $hit (@{$data->{song_hits}}){
print "$hit->{track}->{title}\n";
}
use strict;
use warnings;
my $data = foo();
print "$data\n";
print "$data->{song_hits}\n";
print "$data->{song_hits}[0]\n";
for my $hit (@{$data->{song_hits}}){
print "$hit->{track}->{title}\n";
}
@askvictor
askvictor / lms-cec.py
Last active June 23, 2017 20:14
Squeezebox/LMS send CEC command when play starts
#!/usr/bin/env python
from __future__ import print_function
from future.standard_library import install_aliases
install_aliases()
from urllib.parse import unquote
import select, socket
import cec
config = {
'lms_server': ('192.168.1.10', 9090), # IP of your Squeeze Server, and the network control port (usually 9090)
@askvictor
askvictor / gist:44a89af135fb245b7e1d
Created June 2, 2014 02:39
Messy hack for Plugin.pm in squeezebox youtube plugin to deal with full youtube URLs
(my $x1, my $x2, my $x3, my $x4, my $x5) = ($args->{'search'} =~ /(youtu be\/|youtube com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/);
if ($x5) {
$url = 'youtube://' . $x5;
}