15 May 2025

Adding lockscreen functionality to Raspbian OS

When you install an older version of Raspbian, there is no lock screen option. To add it, instead of going to `/etc/xdg/lxpanel/LXDE-pi/panels/panel` and adding any extra lockscreen lines, simply do this instead:

Technique 1: Screen locks but does not go blank

  • Click the RPi start menu and select Preferences > Main Menu Editor
  • In the editor click New Item and enter the following in the respective fields:
  • Name: Lock
  • Command: /usr/bin/dm-tool lock (don't use dm-tool lock because it is unsafe. The password can be bypassed with Ctrl Alt F7)
  • Command: swaylock
  • Comment: Lock screen
  • Click "Ok" and reboot.

You can also press Ctrl Alt L to lock the screen. 

Technique 2: Screen goes blank, then locks and stays blank

The script below is meant to put the monitor into power saving mode just before swaylock is used to lock the screen (without swayidle, the monitor remains switched on even after the screen is locked). Make sure screen blanking is switched on before using this script by going to Raspberry Pi Preferences > Raspberry Pi Configuration > Display > Screen Blanking.
This script assumes that the screen gets locked only when the User manually selects lock.To make this script runnable on lock, go to Preferences > Main Menu Editor and create a new item with the path and name of this script's file as the "command". For example: /home/<your username>/lock_screen.sh
The default swayidle command would be preconfigured in /home/<your username>/.config/labwc/autostart as swayidle -w timeout 600 'wlopm --off \*' resume 'wlopm --on \*' . The script below would override the default swayidle by killing the swayidle process.


Create the following script in your Raspberry Pi home directory with the name lock_screen.sh (or whatever name you prefer).

#!/bin/bash

# Kill existing swayidle processes
pkill -f swayidle

# Run swayidle with timeout 1. Screen blanking will happen after 1 second
# wlopm is Wayland output power management. See its man page
swayidle -w timeout 1 'wlopm --off \* ; swaylock &' resume 'wlopm --on \* ; pkill -f swayidle' 

# Set screen blanking to 5 minutes (300 seconds)
swayidle -w timeout 300 'wlopm --off \*' resume 'wlopm --on \*' &


To detect if the screen is blanked

You can run `wlopm -j`, and the power mode being on or off will tell you if the screen is blanked or not.

To detect if the screen is locked

#!/bin/bash

#PROCESS_PATH="/usr/sbin/pi-greeter"
PROCESS_PATH="swaylock"

while sleep 2
    do
        if pgrep -f "$PROCESS_PATH" > /dev/null
        then
            echo "$PROCESS_PATH is running. Screen is locked"
        else
            echo "$PROCESS_PATH is not running. Screen is not locked"
        fi
done
 

Some bonus info: If you don't like the bright white wallpaper of the login screen, you can change it in /etc/lightdm/pi-greeter.conf
 
There really needs to be a better, standardized way to detect screen locks across operating systems.

06 May 2025

DeepWiki offers a free repository explanation powered by Devin

I've always wanted a software that would explain everything about a repository and the code. I even considered building one, when I came across explanations that even SourceTrail was unsuccessful since people were unwilling to purchase it at scale. Even employers didn't see the value in buying one. Did you know that Grappl shows code like buildings? There are a bunch of other tools like Sourcery and SourceGraph, but today I came across a clever website named DeepWiki, created by Cognition.ai (the creators of Devin).


If you have a public GitHub repository, you can simply replace the "github.com" with "deepwiki.com", and it'll offer you a full repository analysis and description in a few minutes. They'll email you to notify.

https://github.com/nav9/splitVideoQualityViewer 

https://deepwiki.com/nav9/splitVideoQualityViewer  

I tried it, and was quite impressed at the flowcharts it created. The visualizations even showed me flows that I didn't remember existed. It also shows and explains the code structure and every class. At the bottom of the screen it provides a textfield using which you can ask it questions about the codebase

To test it out initially, I tried asking it about "who first discovered India", to see if it'd respond without thinking, similar to how many GPT's do. It however responded well by saying that "I notice that your query "who first discovered India" doesn't appear to be related to the Split Video Quality Viewer codebase that I'm currently analyzing. The codebase you're viewing is a tool for comparing multiple videos side-by-side in a split-screen layout, not a historical database or information system about the discovery of India...". I was impressed again. It actually scans the code to generate a response. 

I tried submitting simple programs too, created in GW-BASIC:

  • Jump-up: The first game I created. DeepWiki created an impressive analysis and visualization of the game character and flow of the game. Didn't expect it to be this good.
  • Digger:  It actually analyzed and visualized how my Digger games improved over time and created nice flowcharts of the monster's AI thinking.

 I even submitted iRest, and again, it created a useful visualization.

Since the website is named DeepWiki, I don't think they would be using it only for code. It seems general purpose enough to be used as a deep search for any website. Perhaps even the entire Internet.  

I highly recommend DeepWiki.