= SPEC-002: Tracking Link Usage on Linux :sectnums: :toc:
== Background
To track how many times a specific link has been opened on a public library's desktop, a solution is needed that logs each time the link is accessed. This solution must work locally without the ability to run scripts on the website.
== Requirements
- Log each time the link is accessed.
- Store the log file locally.
- Ensure the solution is easy to set up and use on Linux.
== Method
The method involves creating a shell script that logs each access to a file and then opens the web link. This script is then linked to a desktop shortcut to make it easily accessible.
== Implementation
-
Create the shell script
log_and_open_link.sh
:#!/bin/bash logFile="$HOME/Documents/link_usage_log.txt" echo "$(date)" >> "$logFile" xdg-open "http://your-weblink.com"
-
Make the script executable:
chmod +x ~/log_and_open_link.sh
-
Create a desktop shortcut:
- Create a
.desktop
file:[Desktop Entry] Version=1.0 Name=Are you in need? Comment=Open the resource link and log usage Exec=/home/yourusername/log_and_open_link.sh Icon=utilities-terminal Terminal=false Type=Application
- Make the desktop entry executable:
chmod +x ~/Desktop/Are_you_in_need.desktop
- Create a
== Milestones
- Creation of the shell script.
- Making the script executable.
- Creation and verification of the desktop shortcut.
== Gathering Results
The log file located at ~/Documents/link_usage_log.txt
will record each access, providing a count of how many times the link has been opened.