You are not logged in.

#3826 2025-08-14 14:15:13

Succulent of your garden
Member
From: Majestic kingdom of pot plants
Registered: 2024-02-29
Posts: 855

Re: Post your handy self made command line utilities

Probably some here know this but I'm going to put this for those who maybe doesn't know yet, it uses this https://github.com/chubin/wttr.in :

#!/bin/sh
choice=$(echo "" | dmenu -p 'Please write city to check weather: ')
link="wttr.in/$choice"
kitty --hold -- bash -c "curl $link; read -p 'Press Enter to exit'"

I use it with a keybinding to launch it quickly without the terminal and check the weather where I lived. Obviously you can check the weather in anywhere of the world. most of the time have a decent accuracy of the weather. It's a very short and minimal script but it's very useful to me. I use dmenu to insert the city and kitty. The kitty usage is just because of the graphics capabilities since is not my default terminal, but you can use it in any terminal you want with some tweaks. So if someone have a different setup like for example rofi, it could be nice to see the variation of this script here. 

When I'm in a hurry and I need to get outside fast, this scripts makes my day, since I no longer need to go to accuweather to check the weather smile

Last edited by Succulent of your garden (2025-08-14 14:17:53)


str( @soyg ) == str( @potplant ) btw!

Offline

#3827 2025-09-03 17:50:00

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,018
Website

Re: Post your handy self made command line utilities

Small python script that renders a black rectangle window that can be maximized with right click and closed with left click. Use -m to start it in fullscreen. I use it as an OLED screensaver for my laptop while working on an external monitor.

Requires tk package installed.

#!/usr/bin/env python3
import sys
import os
import tkinter as tk

class ToggleFullscreenApp:
    def __init__(self, root, start_fullscreen=False):
        self.root = root
        self.fullscreen = False

        # Initial window size (rectangle)
        self.width = 1280
        self.height = 800
        self.root.geometry(f"{self.width}x{self.height}")  # let WM place it
        self.root.configure(background="black")
        
        pid = os.getpid()
        self.root.title(f"OLED saver [{pid}]")

        # Bind click events
        self.root.bind("<Button-3>", self.toggle_fullscreen)
        self.root.bind("<Button-1>", self.exit_app)

        # Force window manager to place window and get actual geometry
        self.root.update_idletasks()
        x = self.root.winfo_x()
        y = self.root.winfo_y()
        w = self.root.winfo_width()
        h = self.root.winfo_height()
        self.saved_geometry = f"{w}x{h}+{x}+{y}"

        # Start in fullscreen if requested
        if start_fullscreen:
            self.toggle_fullscreen()

    def toggle_fullscreen(self, event=None):
        self.fullscreen = not self.fullscreen
        if self.fullscreen:
            # Save current geometry
            self.root.update_idletasks()
            x = self.root.winfo_x()
            y = self.root.winfo_y()
            w = self.root.winfo_width()
            h = self.root.winfo_height()
            self.saved_geometry = f"{w}x{h}+{x}+{y}"

            # Go fullscreen
            self.root.attributes("-fullscreen", True)
        else:
            # Restore original size and position
            self.root.attributes("-fullscreen", False)
            self.root.geometry(self.saved_geometry)

    def exit_app(self, event=None):
        self.root.quit()


if __name__ == "__main__":
    script_name = sys.argv[0]
    
    if "-h" in sys.argv or "--help" in sys.argv:
        print(
            f"Usage: python3 {script_name} [options]\n\n"
            "Options:\n"
            "  -h, --help      Show this help message and exit\n"
            "  -m              Start the application in fullscreen mode\n\n"
            "Controls:\n"
            "  Right-click     Toggle fullscreen on/off\n"
            "  Left-click      Exit the application"
        )
        sys.exit(0)
    
    start_fullscreen = "-m" in sys.argv
    root = tk.Tk()
    app = ToggleFullscreenApp(root, start_fullscreen=start_fullscreen)
    root.mainloop()

Last edited by karabaja4 (2025-09-11 22:05:52)

Online

Board footer

Powered by FluxBB