#!/usr/bin/env python3
import time
import os
import subprocess


"""
DropBy
Author: Jacob Vlijm
Copyright © 2017-2022 Ubuntu Budgie Developers
Website=https://ubuntubudgie.org
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or any later version. This
program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. You
should have received a copy of the GNU General Public License along with this
program.  If not, see <https://www.gnu.org/licenses/>.
"""

dropby_user = os.environ["USER"]
timer = "/tmp/" + dropby_user + "_keepdropbywin"


try:
    os.remove(timer)
except FileNotFoundError:
    pass


t = 0
while True:
    time.sleep(1)
    if not os.path.exists(timer):
        t = t + 1
    else:
        t = 0
    if t >= 6:
        subprocess.Popen(["/usr/bin/wmctrl", "-c", "dropby_popup"])
        break
