Skip to content

Commit

Permalink
Add a sleep reminder notification on personal computer
Browse files Browse the repository at this point in the history
  • Loading branch information
OrBin committed Aug 15, 2024
1 parent b337a93 commit c617af1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions configuration/notify_sleep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

export DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-"unix:path=/run/user/$(id -u)/bus"}

if [[ "$(gnome-screensaver-command --query)" = "The screensaver is active" ]]; then
echo "Screen is locked, exiting"
exit
fi

notify-send -t 300000 'Go to sleep!' 'Screen will be locked in 2 minutes'
sleep 120
gnome-screensaver-command --activate
1 change: 1 addition & 0 deletions tasks/basic-linux-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- zsh
- simplescreenrecorder
- dconf-editor
- libnotify-bin
become: yes

- name: Check if oh-my-zsh is installed
Expand Down
16 changes: 16 additions & 0 deletions tasks/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@
file:
path: "{{ ansible_user_dir }}/bin"
state: directory
register: scripts_dir

- name: Copy notify_sleep.sh
copy:
src: "{{ playbook_dir }}/configuration/notify_sleep.sh"
dest: "{{ scripts_dir.path }}/notify_sleep.sh"
register: notify_sleep_script
when: computer_type == "personal"

- name: Add notify_sleep.sh to cron
ansible.builtin.cron:
name: notify_sleep
minute: "*/15"
hour: "0-4"
job: "{{ notify_sleep_script.dest }}"
when: computer_type == "personal"

- name: Set ptrace_scope for Go debugging
ansible.builtin.replace:
Expand Down

0 comments on commit c617af1

Please sign in to comment.