Skip to content

Instantly share code, notes, and snippets.

View plembo's full-sized avatar

Phil Lembo plembo

View GitHub Profile
@plembo
plembo / you-need-spice-vdagent.md
Last active April 15, 2024 19:02
You need spice-vdagent

You need spice-vdagent

Debian or Kali Linux installed to as KVM (libvirtd) guests do not automatically have qemu-guest-agent or spice-vdagent installed. This will prevent seamless movement of the mouse cursor between the guest and host desktop in Virtual Machine Manager (requiring the use of a Ctrl-Alt to release the cursor from the guest window).

To cure this, install both qemu-guest-agent and spice-vdagent on each guest and reboot (the guests).

$ sudo apt install qemu-guest-agent
$ sudo apt install spice-vdagent
@plembo
plembo / linux-pyperclip-copy.md
Last active April 15, 2024 18:23
Linux workaround for pyperclip.copy

Linux workaround for pyperclip.copy

Al Sweigart's pyperclip library for Python attempts to provide cross-platform methods for interacting with the clipboard on a computer desktop. I and others have found that the .copy method does not work with our Linux desktops (mine is currently Ubuntu 18.04 LTS with the default Gnome Shell).

A workaround was identified gkotian in an issue opened on the project's Github repo.

Here's the snippet provided by gkotian, which I used in a project from Al's Automate the Boring Stuff with Python book.:

@plembo
plembo / 3dgraphicskvmwinubt.md
Last active April 15, 2024 15:05
3D Accelerated Graphics on a Ubuntu KVM Windows guest

3D Accelerated Graphics on a Ubuntu KVM Windows guest

NOTE: Full disclosure, this stopped working for me. No idea why. Maybe because I installed an NVIDIA card? Perhaps 24.04 will fix it? (doubtful, but "hope springs eternal").

Running Ubuntu 22.04 LTS with the stock qemu-kvm/libvirt.

Everything described below was done in virt-manager. The latest Virtio ISO for my platform (x86_64) was downloaded and mounted on the guest's virtual CDROM.

The trick, beyond installing the Virtio drivers (for me, by double-clicking virtio-win-gt-x64.msi), is to make sure that Display Spice has a Listen type of "None" and the OpenGL box is checked before changing the Video Model to Virtio and checking the 3D accceleration box there.

If you do it in that order, you shouldn't get those ugly error messages and the system will recognize you have 3D accelerated graphics. Whether this will actually help you run 3D accelerated soft

@plembo
plembo / nmbrnetkvm.md
Last active April 12, 2024 11:08
NetworkManager bridged network for KVM guests

Setting up a bridged network for KVM guests

This will work with either networkd or NetworkManager as a resolver. In fact, this is the only way to do bridged KVM (libvirtd) networking with NetworkManager.

If you're using NetworkManager (on a desktop or laptop, for example) on your KVM host, follow these instructions to set up a bridge interface.

Once you have the host bridge set up, proceed as follows:

  1. Create a bridge network device inside KVM. Edit and save the below text as file host-bridge.xml:
@plembo
plembo / addbr0ubunmcli.md
Last active April 10, 2024 11:28
Add br0 to Ubuntu desktop using nmcli

Add a bridge interface to Ubuntu desktop using nmcli

Had to do this for some advanced networking with KVM, and couldn't figure out how to do it using the Nework Manager gui. Did find an article later that showed how to do it with nmtui, but it's so much easier to record what you did when using the cli.

To see what everything looks like before starting:

$ nmcli con show
@plembo
plembo / asusb250mcfans.md
Last active April 10, 2024 10:54
Monitoring ASUS Prime B250M-C fans on Linux with lm-sensors

Monitoring ASUS Prime B250M-C fans with lm-sensors

Introduction

The lm-sensors package is the standard software used to monitor things like CPU temperature on Linux. All major distributions include this package. Basic configuration, using the sensors-detect utility, is straightforward. For many systems, running sensors-detect and accepting the defaults is enough to get full functionality.

ASUS Prime B250M-C motherboard

The basic configuration for lm-sensors will provde temperatures for the CPU and ASUS Prime B250M-C motherboard, but not fan speeds.

@plembo
plembo / ghpwithnamecheap.md
Last active April 10, 2024 01:53
GitHub Pages with Namecheap custom domain

Using GitHub Pages with a custom domain: Namecheap Edition

As often happens, I found the official documentation and forum answers to be "close, but no cigar", and so had to experiment a little to get things working.

The main problem for me was a lack of concrete configuration examples. That's not entirely GitHub's fault: having migrated from Google Domains to Namecheap in the middle of this project, I was once again reminded of how many different ways there are to do things in the name service universe [1].

Although you'd think the simplest setup would be to merely configure for the subdomain case (https://www.example.com), in my experience using the apex domain (https://example.com) instead resulted in fewer complications.

Procedure

So here's my recipe for using a custom domain with GitHub pages where Namecheap is the DNS provider:

@plembo
plembo / gitpython-clone-git.md
Last active April 9, 2024 14:46
Clone git repo using GitPython

Git clone using GitPython

In general, I find GitPython's doc to be difficult to parse, mostly because the examples are written in the same kind of manpage notation that gave me a steep learning curve back when I was first learning Unix.

After searching for awhile, I found this page of the doc that tries to show how to clone a remote repo:

https://gitpython.readthedocs.io/en/stable/tutorial.html#examining-references

I didn't find it that obvious, and had to do some trial and error in the python shell before I got it right.

Here's an actual working example you can try:

@plembo
plembo / RPIwithQEMU.md
Last active April 9, 2024 08:09
Emulating a Raspberry Pi with QEMU

Emulating a Raspberry Pi with QEMU

Goal: Emulate a Raspberry Pi with QEMU in order to run the Raspbian O/S (based on Debian Linux).

The current setup is not ideal. For one thing, the maximum RAM allowed using the "versatile-pb" firmware is 256 Mb. In addition, only the most basic peripherals, a keyboard and mouse, are supported.

A number of articles have been written on this topic. Most are outdated, and the few recent ones are missing key information.

@plembo
plembo / vmwp-no3d-avail.md
Last active March 31, 2024 22:51
VMware Player: No 3d support available from the host

VMware Player: "No 3d support is available from the host"

Facts: VMware Player on Ubuntu 18.04 LTS with the standard Gnome desktop running an AMD WX-2100 graphics card. Both glxinfo and glxgears show 3d acceleration is enabled and working on the host. In addition to VMware Player, the host is also running the qemu-kvm/libvirtd stack from Ubuntu's official repositories. My use case for 3d accelerated graphics in a Windows guest is to occasionally play a Windows-only game.

Issue: Player barks this warning during installation of... anything.

Solution: This askubuntu post, Powered by StackExchange[TM], provides the solution: