Aplicación de recordatorio de cumpleaños en Python

Esta aplicación ayuda a recordar los cumpleaños y notificar los cumpleaños de tus amigos. Esta aplicación utiliza notificaciones de Python y Ubuntu para notificar a los usuarios cada vez que se inicia el sistema.

# Python program For
# Birthday Reminder Application
  
# time module is must as reminder 
# is set with the help of dates
import time
  
# os module is used to notify user 
# using default "Ubuntu" notification bar
import os
  
# Birthday file is the one in which the actual birthdays
# and dates are present. This file can be 
# manually edited or can be automated. 
# For simplicity, we will edit it manually.
# Birthdays should be written in this file in
# the format: "MonthDay Name Surname" (Without Quotes)
  
birthdayFile = '/path/to/birthday/file'
  
def checkTodaysBirthdays():
    fileName = open(birthdayFile, 'r')
    today = time.strftime('%m%d')
    flag = 0
    for line in fileName:
        if today in line:
            line = line.split(' ')
            flag =1
            # line[1] contains Name and line[2] contains Surname
            os.system('notify-send "Birthdays Today: ' + line[1]
            + ' ' + line[2] + '"')
    if flag == 0:
            os.system('notify-send "No Birthdays Today!"')
  
if __name__ == '__main__':
    checkTodaysBirthdays()

Agregar el script al inicio

Después de escribir el código anterior, ahora es el momento de agregar este script de Python al inicio. Esto se puede hacer en Ubuntu de la siguiente manera:

  1. En primer lugar, tenemos que crear un archivo ejecutable para nuestro script recordatorio.py
  2. Esto se puede hacer escribiendo el siguiente comando en la terminal
    sudo chmod +x reminder.py, where reminder.py is our script file name 
  3. Ahora tenemos que transferir este archivo a la ruta donde Linux busca sus archivos predeterminados:
    Escriba este comando en la terminal:
     sudo cp /path/to/our/reminder.py /usr/bin

    . Esto agregará nuestro script ejecutable a /usr/bin.

  4. En la búsqueda global, busque Aplicaciones de inicio
  5. Haga clic en Agregar y proporcione el nombre deseado para su proceso
  6. Escriba el comando. Por ejemplo, nuestro nombre de archivo es recordatorio.py , luego escriba recordatorio.py en el campo de comando y seleccione Agregar

NOTA : El script se ejecuta automáticamente (una vez agregado al inicio) cada vez que inicia su sistema. Además, si tiene más de dos cumpleaños el mismo día, ambos cumpleaños se notificarán en la notificación.

Cómo debería verse el archivo de cumpleaños

Salida después de ejecutar el script

Este artículo es una contribución de Omkar Pathak . Si te gusta GeeksforGeeks y te gustaría contribuir, también puedes escribir un artículo usando write.geeksforgeeks.org o enviar tu artículo por correo a review-team@geeksforgeeks.org. Vea su artículo que aparece en la página principal de GeeksforGeeks y ayude a otros Geeks.

Escriba comentarios si encuentra algo incorrecto o si desea compartir más información sobre el tema tratado anteriormente.

Publicación traducida automáticamente

Artículo escrito por GeeksforGeeks-1 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *