Skip to content

fix(daemon): replace hardcoded username with $USER in systemd service#133

Merged
AnnatarHe merged 1 commit intomainfrom
claude/issue-132-20251006-1213
Oct 6, 2025
Merged

fix(daemon): replace hardcoded username with $USER in systemd service#133
AnnatarHe merged 1 commit intomainfrom
claude/issue-132-20251006-1213

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Fixes #132

Updated the systemd service file to use $USER instead of hardcoded username in the ExecStart command. This allows the service to dynamically resolve the current user's shell.

Generated with Claude Code

Co-authored-by: Le He <AnnatarHe@users.noreply.github.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the shelltime-daemon systemd service by introducing dynamic user resolution. The core change involves replacing a hardcoded username with the $USER environment variable in the ExecStart command, which significantly improves the service's adaptability and robustness across different user environments without requiring manual configuration changes for each user.

Highlights

  • Dynamic User Resolution: The systemd service file for shelltime-daemon has been updated to use the $USER environment variable instead of a hardcoded 'username'. This change allows the service to dynamically determine and use the current user's shell.
  • Improved Service Flexibility: By replacing the static username with $USER, the service configuration becomes more flexible and portable, adapting automatically to the user context in which it runs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@AnnatarHe AnnatarHe merged commit 2610348 into main Oct 6, 2025
2 checks passed
@AnnatarHe AnnatarHe deleted the claude/issue-132-20251006-1213 branch October 6, 2025 12:17
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly identifies and fixes a bug in the systemd service file where a username was hardcoded. The fix replaces the hardcoded value with the $USER environment variable. My review includes a suggestion to further improve this by using a systemd-native specifier, which is more robust, efficient, and considered a best practice for systemd unit files.

[Service]
Type=simple
ExecStart=/bin/sh -c 'exec $(getent passwd username | cut -d: -f7) -l -c "/usr/local/bin/shelltime-daemon"'
ExecStart=/bin/sh -c 'exec $(getent passwd $USER | cut -d: -f7) -l -c "/usr/local/bin/shelltime-daemon"'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While using $USER is an improvement over a hardcoded username, it's better practice and more robust to use systemd's own specifiers in unit files. The $USER variable might not always be set in all environments where the service could run, whereas systemd specifiers are guaranteed to be substituted correctly.

You can use the %s specifier, which expands to the user's configured shell from the user database. This simplifies the ExecStart directive significantly and makes it more efficient by avoiding the need to run /bin/sh, getent, and cut just to find the user's shell.

This is cleaner, more efficient, and less prone to errors.

ExecStart=%s -l -c "/usr/local/bin/shelltime-daemon"

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 23.28% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: daemon service description in linux should place $USER instead of username

1 participant