This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| LOGFILE="$HOME/usb_mount_log.txt" | |
| echo "Monitoring USB mount events... Logs will be saved to: $LOGFILE" | |
| # Initialize list of currently mounted devices | |
| existing_mounts=$(lsblk -o NAME,MOUNTPOINT -nr | awk '$2!="" {print $1}') | |
| udevadm monitor --subsystem-match=block --udev | while read -r line; do | |
| if echo "$line" | grep -q "add"; then | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #define KEY_POLL_TEST | |
| struct termios poll_before, poll_new; | |
| struct timeval poll_tv; | |
| fd_set poll_fs; | |
| int poll_init(){ | |
| poll_tv.tv_usec = POLL_TIMEOUT_MICROSECONDS; | |
| poll_tv.tv_sec = POLL_TIMEOUT_SECONDS; | |
| if(tcgetattr(STDIN_FILENO, &poll_before) != 0) return 1; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | cmake_minimum_required(VERSION 3.10) | |
| include(ExternalProject) | |
| ExternalProject_Add(lua | |
| URL "https://www.lua.org/ftp/lua-5.3.5.tar.gz" | |
| CONFIGURE_COMMAND "" | |
| BUILD_COMMAND make generic | |
| BUILD_ALWAYS true | |
| BUILD_IN_SOURCE true | |
| INSTALL_COMMAND "" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function fullcopy(a, b) | |
| for k, v in pairs(a) do | |
| if type(v)=="table" then | |
| b[k] = {} | |
| fullcopy(v, b[k]) | |
| else | |
| b[k] = v | |
| end | |
| end | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | MAX_SIZE = 4 | |
| Ring = {} | |
| function insert(ring, a) | |
| table.insert(ring, a) | |
| if #ring > MAX_SIZE then | |
| table.remove(ring, 1) | |
| end | |
| end |