Minutes 2026-10-29: Difference between revisions

m
fix formatting... oopsie
(create page with the notes)
 
m (fix formatting... oopsie)
 
 
Scripting?
 
Executables are not binary
    Executables are not binary
Files start with #! (Shebang)
 
Defines what binary to run the file in
    Files start with #! (Shebang)
Usually /bin/bash
 
Can do it with other programming langues or anything!
        Defines what binary to run the file in
Good for automation/customization
 
        Usually /bin/bash
 
        Can do it with other programming langues or anything!
 
    Good for automation/customization
 
What languages?
 
Any
    Any
Can even do auto-compiled C with GCC
 
Usually POSIX shell like bash
    Can even do auto-compiled C with GCC
env/bin/bash is more 'proper'
 
Python
    Usually POSIX shell like bash
Some scripts on your system
 
Pacman
        env/bin/bash is more 'proper'
Other shells
 
fish, csh, zsh
    Python
Shell (server) uses ZSH
 
Other shells come with their own languages since that's just what they are
        Some scripts on your system
All high-level
 
All terminal commands are shell commands
        Pacman
Pipes (part of bash language)
 
Bash is part of POSIX standard so it's common on Linux/UNIX
    Other shells
Bash language
 
It's old
        fish, csh, zsh
Bounre shell
 
Dates back to 60s
    Shell (server) uses ZSH
 
    Other shells come with their own languages since that's just what they are
 
    All high-level
 
        All terminal commands are shell commands
 
        Pipes (part of bash language)
 
        Bash is part of POSIX standard so it's common on Linux/UNIX
 
    Bash language
 
        It's old
 
            Bounre shell
 
            Dates back to 60s
 
Use cases
 
Run scripts on keybind
    Run scripts on keybind
You can bind any executable to a keybind
 
Shortcuts (open apps) as well
        You can bind any executable to a keybind
See the weather
 
Interactive menus
        Shortcuts (open apps) as well
dmenu
 
Take in a list of things and sort through them
    See the weather
Useful for menus
 
Repetitive tasks
    Interactive menus
Examples:
 
Transferring pictures off a camera
        dmenu
Freya found a Youtube channel with a lot of cool shell scripts
 
Videos edited with scripts
        Take in a list of things and sort through them
Automated FFmpeg scripts
 
Stringing together data
            Useful for menus
Screenshots
 
Can use slurp/grim on Wayland
    Repetitive tasks
Usually scripted
 
Can make it dynamic
    Examples:
Process data
 
        Transferring pictures off a camera
 
    Freya found a Youtube channel with a lot of cool shell scripts
 
        Videos edited with scripts
 
            Automated FFmpeg scripts
 
    Stringing together data
 
        Screenshots
 
            Can use slurp/grim on Wayland
 
        Usually scripted
 
            Can make it dynamic
 
    Process data
 
Basics of bash
 
No built in functions
    No built in functions
Just call commandline applications
 
Built on commands like cs, ls
        Just call commandline applications
Familiar if you use CLI a lot
 
Bash environment is entirely dependent on what you have installed
    Built on commands like cs, ls
JSON parsing (bad) and dependent on system packages
 
Lots of cool programs to do nice things
    Familiar if you use CLI a lot
Environment variables
 
Just a bash variable
    Bash environment is entirely dependent on what you have installed
East to access in shell environments
 
They can be complicated on other languages
        JSON parsing (bad) and dependent on system packages
Awful syntax but decently powerful
 
Good for stringing commands together with pipes
    Lots of cool programs to do nice things
Variables
 
Assign a string to a name
    Environment variables
Easy to access with $
 
Echo
        Just a bash variable
Print statements
 
Read lines from standard input
        East to access in shell environments
Grab user data
 
If statements must end in fi
        They can be complicated on other languages
Some bash statements are ended with themselves backwards
 
Really weird getting arguments
    Awful syntax but decently powerful
Square brackets with required spaces
 
Brackets are technically a command...
    Good for stringing commands together with pipes
Typical programming languages things (Loops, brackets, else-if)
 
Bash is a mess....
    Variables
Is this how professors feel teaching Java 8 to students?
 
Or C89?
        Assign a string to a name
Exit codes are like return statements to exit or give errors
 
        Easy to access with $
 
    Echo
 
        Print statements
 
    Read lines from standard input
 
        Grab user data
 
    If statements must end in fi
 
        Some bash statements are ended with themselves backwards
 
        Really weird getting arguments
 
            Square brackets with required spaces
 
            Brackets are technically a command...
 
    Typical programming languages things (Loops, brackets, else-if)
 
    Bash is a mess....
 
        Is this how professors feel teaching Java 8 to students?
 
        Or C89?
 
    Exit codes are like return statements to exit or give errors
 
Built-in things
 
$n gets number 0 to 9
    $?n gets errornumber 0 to codes9
 
See if program failed unless it's being weird
    $@? gets arguments aserror arrayscodes
 
$! gets PID of background commnand
        See if program failed unless it's being weird
Lets you run things asynchronously
 
    $@ gets arguments as arrays
 
    $! gets PID of background commnand
 
        Lets you run things asynchronously
 
Environment values
 
Home directory
    Home directory
Current username
 
PATH variable
    Current username
XDG variables
 
.config
    PATH variable
cache home
 
local home
    Don't hardcode paths, useXDG variables instead
 
Better for portability
        .config
 
        cache home
 
        local home
 
    Don't hardcode paths, use variables instead
 
        Better for portability
 
Things to remember
 
Commands make life easy
    Commands make life easy
Learn to use awk, sed, and jq
 
Text replacement
    Learn to use awk, sed, and jq
JSON parsing
 
Curl for internet stuff
        Text replacement
Or wget
 
There's functions
        JSON parsing
Make things easy for yourself
 
But nobody uses them except for fork bombs
    Curl for internet stuff
 
        Or wget
 
    There's functions
 
        Make things easy for yourself
 
        But nobody uses them except for fork bombs
 
Demo time!
 
Window manager mishaps...
    Window manager mishaps...
Example scripts
 
National weather service provides prerendered radar GIFs
    Example scripts
Just a URL
 
Always updated
    National weather service provides prerendered radar GIFs
Can grab them with a script
 
Downloads the gif to /tmp and plays it
        Just a URL
Make widgets?
 
Uses just curl and mpv
        Always updated
QR generator script
 
Save text
        Can grab them with a script
qrencode then print as image
 
Scan QR from screen or camera
            Downloads the gif to /tmp and plays it
All very simple, just stringing shell commands together
 
Aurora script
        Make widgets?
Shows it on a map in a window
 
Free API from NOAA
        Uses just curl and mpv
Graph of probability
 
Script to add todo list item
    QR generator script
Doesn't work...
 
Brightness control
        Save text
Drivers for brightnessctl may be broken
 
Complaining about chromeOS?
        qrencode then print as image
Converts value to percentage
 
Hardcoded path.....
    Scan QR from screen or camera
Waybar extension
 
Outputs todo status to the bar
    All very simple, just stringing shell commands together
Just a loop to show items
 
    Aurora script
 
        Shows it on a map in a window
 
        Free API from NOAA
 
        Graph of probability
 
    Script to add todo list item
 
        Doesn't work...
 
    Brightness control
 
        Drivers for brightnessctl may be broken
 
        Complaining about chromeOS?
 
        Converts value to percentage
 
        Hardcoded path.....
 
    Waybar extension
 
        Outputs todo status to the bar
 
        Just a loop to show items
 
Cronjobs
 
Do custom things on schedules
    Do custom things on schedules
Weather alerts
 
        Weather alerts
 
Scripting Magnum Opus
 
Grabs days of weathers
    Grabs days of weathers
Pulled from weather services
 
Only took 2 hours
    Pulled from weather services
Very easy
 
It's free!
    Only took 2 hours
Don't pay for weather APIs
 
National weather service is free and good
    Very easy
Raw model data is also free
 
Even the notes they're taking
    It's free!
Forecast function takes in URLs and outputs JSON
 
Freya also wrote scripts for brightness and volume
        Don't pay for weather APIs
Wants to bind it to a shortcut
 
        National weather service is free and good
 
        Raw model data is also free
 
            Even the notes they're taking
 
    Forecast function takes in URLs and outputs JSON
 
    Freya also wrote scripts for brightness and volume
 
    Wants to bind it to a shortcut
 
Inspiration
 
Bread on Penguins
    Bread on Penguins
Videos showing scripts
 
Automated with ffmpeg
        Videos showing scripts
Cool things
 
        Automated with ffmpeg
 
        Cool things
 
One more thing
 
LUG lan party 3 on Sunday
    LUG lan party 3 on Sunday
 
End