mirror of
https://github.com/NickHu/sway
synced 2025-01-02 06:20:02 +01:00
Merge pull request #480 from crondog/swaylocktrans2
swaylock: Allow for transparent color values
This commit is contained in:
commit
a6e57dd7ac
1 changed files with 17 additions and 11 deletions
|
@ -211,12 +211,12 @@ int main(int argc, char **argv) {
|
||||||
const char *usage =
|
const char *usage =
|
||||||
"Usage: swaylock [options...]\n"
|
"Usage: swaylock [options...]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -h, --help Show help message and quit.\n"
|
" -h, --help Show help message and quit.\n"
|
||||||
" -c, --color <rrggbb> Turn the screen into the given color instead of white.\n"
|
" -c, --color <rrggbb[aa]> Turn the screen into the given color instead of white.\n"
|
||||||
" -s, --scaling Scaling mode: stretch, fill, fit, center, tile.\n"
|
" -s, --scaling Scaling mode: stretch, fill, fit, center, tile.\n"
|
||||||
" -t, --tiling Same as --scaling=tile.\n"
|
" -t, --tiling Same as --scaling=tile.\n"
|
||||||
" -v, --version Show the version number and quit.\n"
|
" -v, --version Show the version number and quit.\n"
|
||||||
" -i, --image <path> Display the given image.\n";
|
" -i, --image <path> Display the given image.\n";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -227,15 +227,21 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if (strlen(optarg) < 6) {
|
{
|
||||||
fprintf(stderr, "color must be specified in 3 byte format, e.g. ff0000\n");
|
int colorlen = strlen(optarg);
|
||||||
|
if (colorlen < 6 || colorlen == 7 || colorlen > 8) {
|
||||||
|
fprintf(stderr, "color must be specified in 3 or 4 byte format, e.g. ff0000 or ff0000ff\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
color = strtol(optarg, NULL, 16);
|
color = strtol(optarg, NULL, 16);
|
||||||
color <<= 8;
|
|
||||||
color |= 0xFF;
|
if (colorlen == 6) {
|
||||||
|
color <<= 8;
|
||||||
|
color |= 0xFF;
|
||||||
|
}
|
||||||
sway_log(L_DEBUG, "color: 0x%x", color);
|
sway_log(L_DEBUG, "color: 0x%x", color);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'i':
|
case 'i':
|
||||||
image_path = optarg;
|
image_path = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue