Brice Goglin (bgoglin) wrote,
Brice Goglin

XFCE moving icons around when changing monitor sizes

XFCE saves desktop icon positions in a file whose name depends on the desktop size. It means that icon positions are not preserved when switching from laptop-only to laptop + external screen.

Now I run this at the beginning of my XFCE session. Whenever a new positions file is created, I move it back to the default filename (which doesn't depend on the desktop size).

    #!/usr/bin/perl -w

    my $dir = "/home/bgoglin/.config/xfce4/desktop/";

    chdir $dir;

    open WATCH, "inotifywait -m -e moved_to . |"
      or die "Failed to notifywait.\n";

    while ($line = ) {
      next unless $line =~ m/(.*) MOVED_TO (.*)/;
      my $file = $2;
      next if $file =~ m/\.new$/;
      next unless $file =~ m/icons.screen0-.*\.rc/;
      unlink "icons.screen0.rc.bak";
      rename "icons.screen0.rc", "icons.screen0.rc.bak";
      print "Moving $file to icons.screen0.rc\n";
      rename $file, "icons.screen0.rc";
Tags: admin, linux

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded