Differences

This shows you the differences between two versions of the page.

Link to this comparison view

blog:backgrounds_in_gnome [2013/02/12 09:38]
sam created
blog:backgrounds_in_gnome [2013/02/12 10:42] (current)
sam needed to get gnome variables so gsettings would work in cron
Line 7: Line 7:
  
 <code perl> <code perl>
-#​!/​usr/​bin/​perl+#!/usr/bin#​!/​usr/​bin/​perl
  
 use strict; use strict;
Line 34: Line 34:
 my @temp_files;​ my @temp_files;​
  
 +$ENV{"​XAUTHORITY"​} = "/​home/​sam/​.Xauthority";​
  
 +my %gs_env = pgrep_env($ENV{"​USER"​},​ "​gnome-shell"​);​
 +$ENV{"​DBUS_SESSION_BUS_ADDRESS"​} =  $gs_env{"​DBUS_SESSION_BUS_ADDRESS"​};​
  
 +
 # get image files # get image files
 opendir my($dh), $background_dir;​ opendir my($dh), $background_dir;​
Line 88: Line 92:
  
 } }
 +
 +
 +
 +
 +sub pgrep_env {
 + my ($user, $proc_name) = @_;
 + chomp(my $pid = `/​usr/​bin/​pgrep -u $user ^$proc_name\$`);​
 + my $raw_env;
 +
 + {
 + local $/;
 + open(IN, "/​proc/​$pid/​environ"​);​
 + $raw_env = <IN>;
 + close(IN);​
 + }
 +
 + my %return;
 + foreach (split('​\0',​ $raw_env)) {
 + (my @F) = split(/\=/, $_, 2);
 +
 + $return{"​$F[0]"​} = $F[1];
 + }
 +
 +
 + return %return;
 +
 +
 +}
 +
 +
 +
 </​code>​ </​code>​
  
 ~~LINKBACK~~ ~~LINKBACK~~
 ~~DISCUSSION~~ ~~DISCUSSION~~