Exemple #1
0
    )
    optional_parser_group.add_argument(
        "-r",
        "--restart",
        help="restart command automatically",
        action="store_true",
    )
    optional_parser.add_argument(
        "-n", "--dryrun", help="run in dryrun mode", action="store_true"
    )

    args = parser.parse_args()

    EXECUTABLE = args.COMMAND.split()[0]

    shell(f"killall -I -q -w {EXECUTABLE}", dryrun=args.dryrun)

    if args.daemonize:
        pidfile = f"/tmp/{slugify(args.COMMAND)}.pid"

        try:
            with open(pidfile, "r") as pf:
                pid = int(pf.read().strip())
        except IOError:
            pid = None

        if pid:
            sys.stderr.write(
                f"pidfile {pidfile} already exists. Daemon already running?\n"
            )
            sys.exit(1)
Exemple #2
0
    optional_parser.add_argument(
        "-h",
        "--help",
        help="show this help message and exit",
        action="help",
        default=argparse.SUPPRESS,
    )
    optional_parser.add_argument("-n",
                                 "--dryrun",
                                 help="run in dryrun mode",
                                 action="store_true")

    args = parser.parse_args()

    if args.CONFIGURATION == "desktop":
        if args.ACTION == "start" or args.ACTION == "restart":
            shell(
                'df_launcher.py "redshift -P -t 3500:2500 -l 40.7128:-74.0060" -d'
            )
        elif args.ACTION == "stop":
            shell("killall -I -q -w redshift")
            shell("redshift -x")
    elif args.CONFIGURATION == "laptop":
        if args.ACTION == "start" or args.ACTION == "restart":
            shell(
                'df_launcher.py "redshift -P -t 5500:2500 -l 40.7128:-74.0060" -d'
            )
        elif args.ACTION == "stop":
            shell("killall -I -q -w redshift")
            shell("redshift -x")
Exemple #3
0
#!/usr/bin/env python

from dotfiles import shell
import sys

if __name__ == "__main__":
    rc, PRIMARY, _ = shell(
        "xrandr --query | grep '\\bprimary\\b' | cut -d\" \" -f1")

    rc, stdout, _ = shell(
        "xrandr --query | grep '\\bconnected\\b' | grep -v '\\bprimary\\b' | cut -d\" \" -f1"
    )
    CONNECTED_MONITORS = stdout.split("\n")

    if rc == 0:
        DP__1_5 = [c for c in CONNECTED_MONITORS
                   if "DP" in c and "-1-5" in c][0]
        DP_ = [c for c in CONNECTED_MONITORS
               if "DP" in c and "-1-5" not in c][0]
    else:
        sys.exit(1)

    rc, stdout, _ = shell(
        "xrandr --query | grep '\\bdisconnected\\b' | grep -v '\\bprimary\\b' | cut -d\" \" -f1"
    )
    DISCONNECTED_MONITORS = stdout.split("\n")

    shell(
        f"xrandr --output {PRIMARY} --off --output {DP__1_5} --mode 1920x1080 --pos 0x0 --rotate normal --output {DP_} --mode 1920x1080 --pos 1920x0 --rotate normal {' '.join([f'--output {c} --off' for c in DISCONNECTED_MONITORS])}"
    )