This repository was archived by the owner on Aug 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle-dark.php
More file actions
executable file
·106 lines (85 loc) · 2.49 KB
/
Copy pathtoggle-dark.php
File metadata and controls
executable file
·106 lines (85 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env /usr/bin/php
<?php
use Dionysopoulos\ToggleDark\ToggleDark;
use Silly\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
require_once __DIR__ . "/vendor/autoload.php";
$app = new Application();
$app->command(
'autotoggle',
function (OutputInterface $output, InputInterface $input) {
$toggleDark = new ToggleDark();
$ioStyle = new Symfony\Component\Console\Style\SymfonyStyle($input, $output);
$limits = $toggleDark->getDaytimeLimits();
$tz = new DateTimeZone($toggleDark->getTimezone());
$ioStyle->info(
sprintf(
'Daylight today is from %s to %s.',
$limits->start->setTimezone($tz)->format('H:i:s T'),
$limits->end->setTimezone($tz)->format('H:i:s T')
)
);
$toggled = $toggleDark->autoToggleScheme();
if ($toggled)
{
$ioStyle->success('Toggled Plasma colour scheme.');
return;
}
$ioStyle->warning('No need to toggle the Plasma colour scheme.');
}
)->descriptions('Toggle dark/light colour scheme based on sunrise/sunset');
$app->command(
'toggle',
function (OutputInterface $output) {
(new ToggleDark())->toggleScheme();
}
)->descriptions('Toggle between the dark and light colour scheme');
$app->command(
'dark',
function (OutputInterface $output) {
(new ToggleDark())->forceDark();
}
)->descriptions('Applies the dark colour scheme');
$app->command(
'light',
function (OutputInterface $output) {
(new ToggleDark())->forceLight();
}
)->descriptions('Applies the light colour scheme');
$app->command(
'current',
function (OutputInterface $output) {
$current = (new ToggleDark())->getCurrentScheme();
$output->writeln($current);
}
)->descriptions('Print the current colour scheme identifier');
$app->command(
'update',
function (OutputInterface $output) {
$toggleDark = new ToggleDark();
$toggleDark->updateCRON();
$toggleDark->autoToggleScheme();
$output->writeln('Updated CRON jobs.');
}
)->descriptions('Install or update the CRON jobs to auto-switch the colour scheme');
$app->command(
'uninstall',
function (OutputInterface $output) {
(new ToggleDark())->uninstallCRON();
$output->writeln('Removed CRON jobs.');
}
)->descriptions('Remove the CRON jobs to auto-switch the colour scheme');
call_user_func(
function () {
$self = __FILE__;
if (str_starts_with($self, 'phar://'))
{
$self = substr($self, 7);
$self = dirname($self);
}
define('TOGGLE_DARK_SELF', $self);
}
);
$app->setDefaultCommand('autotoggle');
$app->run();