diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2015-05-02 09:53:00 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2015-05-02 09:53:00 +0200 |
commit | 5682ab44e3ecca0a18404885bcfbf97b8762a89b (patch) | |
tree | 10ca46f93134fb36640b49353e9c578ef24ba8a5 /mga-bg-res/mga-bg-res.c | |
parent | 3e6f62173f00b6f60050c07485948bfbbb4b59ba (diff) | |
download | theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar.gz theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar.bz2 theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.tar.xz theme-5682ab44e3ecca0a18404885bcfbf97b8762a89b.zip |
Make mga-bg-res a systemd service that uses monitor-probe
Now runs as a systemd service with root privileges, therefore the mga-bg-res C binary is no longer needed.
Uses monitor-probe to find the optimal resolution when X is not yet started, and handles cases where monitor-probe fails by defaulting to 4:3 aspect ratio.
Diffstat (limited to 'mga-bg-res/mga-bg-res.c')
-rw-r--r-- | mga-bg-res/mga-bg-res.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/mga-bg-res/mga-bg-res.c b/mga-bg-res/mga-bg-res.c deleted file mode 100644 index 6061587..0000000 --- a/mga-bg-res/mga-bg-res.c +++ /dev/null @@ -1,82 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <unistd.h> - -#define PATH "/usr/share/mga/backgrounds/" -#define DSTLINK PATH"default.jpg" -#define SRCLINK_PREFIX PATH"Mageia-Default-" -#define SRCLINK_SUFFIX ".jpg" -#define SRCLINK SRCLINK_PREFIX"%s"SRCLINK_SUFFIX -#define RESSIZE 20 -#define SRCSIZE (RESSIZE+strlen(SRCLINK_PREFIX)+strlen(SRCLINK_SUFFIX) + 1) -#define ALLOWCHARS "0123456789x" - -int main(int argc, char* argv[]) { - char src[SRCSIZE]; - char res[RESSIZE]; - int l; - - // check argument - if (argc != 2) { - fprintf(stderr, "Need a resolution argument, eg: '1920x1080'.\n"); - return 1; - } - - // get the res (max RESSIZE) - l = snprintf(res, RESSIZE, argv[1]); - if (l < 5) { - fprintf(stderr, "Malformed resolution argument, eg: '1920x1080'.\n"); - return 2; - } - - // to be sure, set the last char as 0 - if (l < RESSIZE) - res[l] = 0; - else - res[RESSIZE-1] = 0; - - // check if the resolution contains acceptable chars - l = strspn(res, ALLOWCHARS); - if (l < 5) { - fprintf(stderr, "Malformed resolution argument, eg: '1920x1080'.\n"); - return 2; - } - - // to be sure, set the last char as 0 - if (l < RESSIZE) - res[l] = 0; - else - res[RESSIZE-1] = 0; - - // create target string - if (snprintf(src, SRCSIZE, SRCLINK, res) < 0) { - fprintf(stderr, "Unknown error determining symlink target.\n"); - return 3; - } - - // check if symlink target exists - if (access(src, F_OK) < 0) { - fprintf(stderr, "No image for this resolution.\n"); - return 0; - } - - // set symlink - if (symlink(src, DSTLINK) < 0) { - if (errno != EEXIST) { - fprintf(stderr, "Symlink could not be set: %s.\n", strerror(errno)); - return 4; - } - - // since the destination exists, remove and try again - if (unlink(DSTLINK) < 0) { - fprintf(stderr, "Symlink could not be forced: %s.\n", strerror(errno)); - return 5; - } - if (symlink(src, DSTLINK) < 0) { - fprintf(stderr, "Unknown error during forced symlink: %s.\n", strerror(errno)); - return 6; - } - } - return 0; -} |