File: desktop-profiles_pshrc.pl

package info (click to toggle)
desktop-profiles 1.4.22
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,096 kB
  • ctags: 6
  • sloc: sh: 841; perl: 58; makefile: 48; csh: 8
file content (32 lines) | stat: -rwxr-xr-x 1,034 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl

# This fixes the desktop-profiles corner-case where a graphical client is 
# started through an 'ssh -X' session in which the Xsession.d scripts are 
# not run, so we need to make sure the profiles are activated according to
# the specified settings at login).
$DESKTOP_PROFILES_SNIPPET = '/usr/share/desktop-profiles/get_desktop-profiles_variables';

if ( -e $DESKTOP_PROFILES_SNIPPET ) {
  $TEMP_FILE = `tempfile`;

  # get rid of extranous newline, which messed things up later
  { $TEMP_FILE =~ s/\n// }

  # use bash to write the required environment settings to a tempfile
  # this file has a 'VARIABLE=VALUE' format
  `bash $DESKTOP_PROFILES_SNIPPET $TEMP_FILE`;

  # source to set the required environment variables
  # needs to become: $ENV{'VARIABLE'} = 'VALUE'; 
  {
    open(input, $TEMP_FILE);
    while($env_var = <input>) {
      # needs to become: $ENV{'VARIABLE'} = 'VALUE'; 
      $env_var =~ s/^(.*)=(.*)$/\\\\$ENV{'\1'} = '\2'/ ;
      eval $env_var;
    }
  }
  
  # cleanup
  `rm $TEMP_FILE`;
}