Controlling Xorg's Composite under FVWM

This module + scripts allows you to control Xorg’s Composite features under Fvwm.

I aquired it off another forum a long time ago and have noticed any links to such are currently broken.

I paste it now for the bennefit of others and, hopefully, contributions/improvements will arise.

There is another post about this on this forum which has some instructions.

viewtopic.php?t=27&start=0&postdays=0&postorder=asc&highlight=

I have modified the scripts from the original posting, but changes were only slight.

I believe I changed the default transparency for new windows and made some changes to settrans.pl that affected how fluidly it changes transparency.

I also changed the application used in settrans.pl from transset to transset-df

“FvwmTransset”

#!/usr/bin/perl   

use lib `fvwm-perllib dir`;
use FVWM::Module;

my $module = new FVWM::Module;

# Get to the right directory;
chdir;
my $defaultsFile = ".fvwm/trans.defaults" or die "No config file";
my $tempFile = ".fvwm/trans.temp";

# Clean out temporary file in preparation
# to run
sub startup
{
 my $cmd = "rm -f " . $tempFile;
 system($cmd);
 
 $cmd = "touch " . $tempFile;
 system($cmd);
}
# Called by FVWM for every created window
sub onWindowCreate
{
 my $win_id = $_[1]->_win_id;
 $win_id = oct($win_id) if $win_id =~ /^0/;
 my $trans = 0.90; # Default transparency of 0.95 on all windows
 open(DEFAULTS, "<", $defaultsFile);
 
 while(my $line = <DEFAULTS>)
 {
  # Token 0 is the window property to match against
  # Token 1 is the value to match
  # Token 2 is the default transparency level
  chomp($line);
  my @tokens = split(/:/, $line);
 
  # Each iteration checks to see if the supplied variable is defined
  # for this window via xprop, and then checks to see if the matching
  # criteria is met, if it is, use that transparency
  my $test = "xprop -id " . $win_id . " | grep " . @tokens[0];
  my $result = `$test`;
  if($result =~ m/@tokens[1]/)
  {
   $trans = @tokens[2];
   # Don't bother with the other lines
   break;
  }
 }
 
 close(DEFAULTS);

 if($trans < 1.0)
 {
  my $tempEntry = $win_id . ":" . $trans;
 
  open(TEMP, ">>", $tempFile);
  print TEMP $tempEntry . "\n";
  close(TEMP);
 
  #my $ex = "transset-df " . $trans . " -id " . $win_id;
  print "Trying to set transparency with: " . $ex . "\n";
  system("transset-df","-i",$win_id,$trans);
  #system($ex);
 }
}

sub onWindowDestroy
{
 my $win_id = $_[1]->_win_id;
 $win_id = oct($win_id) if $win_id =~ /^0/;
 open(TEMP, "<", $tempFile);

 my %transHash;
 
 while(my $line = <TEMP>)
 {
          my @temp = split(/:/, $line);
  $transHash{@temp[0]} = @temp[1];
 }

 close(TEMP);

 delete($transHash{$win_id});

 open(TEMP, ">", $tempFile);

 # Re-output the whole temp file, with new value
 my @keys = keys %transHash;
 my @values = values %transHash;
 
 while(@keys)
 {
  my $temp = pop(@keys) . ":" . pop(@values);
  print TEMP $temp;
 }
 
 close(TEMP);
}

startup();

$module->addHandler(M_ADD_WINDOW, \&onWindowCreate);
$module->addHandler(M_DESTROY_WINDOW, \&onWindowDestroy);
$module->eventLoop; 

“settrans.pl”

#!/usr/bin/perl

# Arguments:
# 1) A window ID in hex or decimal
# 2) Either "+" or "-" (without quotes)
# Indicates direction of transparency stepping,
# and steps by 5
# + Means make more transparent ($trans -= 5)
# - Means make less transparent ($trans += 5)

my $win_id = @ARGV[0];
$win_id = oct($win_id) if $win_id =~ /^0/;
my $direction = @ARGV[1];
my $tempFile = "/dev/shm/trans.temp";

if((($direction ne "+") && ($direction ne "-")))
{
 die "Wrong arguments\n";
}

chdir;
open(TEMP, "<", $tempFile);

# Transparency levels keyed by window ID
my %transHash;

while(my $line = <TEMP>)
{
 chomp($line);
 my @temp = split(/:/, $line);
 $transHash{@temp[0]} = @temp[1];
}

close(TEMP);


# Make less transparent
if($direction eq "-")
{
 # If the window isn't transparent (according to temp file)
 # then just quit out (die), since it can't really be less transparent
 if(!defined($transHash{$win_id}))
 {
  die $win_id . " already fully opaque\n";
 }

 $trans = $transHash{$win_id};
 
 if($trans < 1.0)
 {
  $trans += 0.05;
 }
}
# Make more transparent
else
{
 if(!defined($transHash{$win_id}))
 {
  $trans = 0.95;
 }
 else
 {
  $trans = $transHash{$win_id};
   
  if($trans > 0.1)
  {
   $trans -= 0.05;
  }
 }
}

#my $cmd = "transset-df " . $trans . " -id " . $win_id;
#system($cmd);
system("transset-df","-i",$win_id,$trans);

# Update the hash with the new value
$transHash{$win_id} = $trans;

open(TEMP, ">", $tempFile);


# Re-output the whole temp file, with new value
my @keys = keys %transHash;
my @values = values %transHash;

while(@keys)
{
 my $temp = pop(@keys) . ":" . pop(@values) . "\n";
 print TEMP $temp;
}

close(TEMP); 

“trans.defaults”

WM_NAME:Lists de contacts:0.7
WM_CLASS:rxvt:0.5
WM_CLASS:psi:0.8
WM_RESOURCE:urxvt:0.5
WM_CLASS:Pympd:0.6

FvwmTransset goes in your fvwm modules dir

settrans.pl and trans.defaults go in ~/.fvwm/

I use transset-df to manualy modify the transparency of my windows

Mouse 4 W       CM   Exec exec transset-df -p --inc 0.1   
Mouse 5 W       CM   Exec exec transset-df --min 0.1 -p --dec 0.1

[code]:phone: cat switch-xcomp.bash
#!/bin/bash

pgrep -l xcompmgr
if [ $? -eq 0 ]
then
#FvwmCommand “SendToModule DockButtons ChangeButton trans Icon /home/exp/.fvwm/theme/trans_off.png”
killall -9 xcompmgr
else
#FvwmCommand “SendToModule DockButtons ChangeButton trans Icon /home/exp/.fvwm/theme/trans_on.png”
nohup xcompmgr -cf &
fi
[/code]

i use this. and

☎ grep trans * f.action:Mouse 4 1 A Exec exec transset-df --inc 0.1 -i $[w.id] f.action:Mouse 5 1 A Exec exec transset-df --dec 0.1 -i $[w.id]

I would love to see some screenshots