Skip to content

Commit

Permalink
Defaults to concatenating /tmp/ns.USER.SCREEN/wmii if no WMII_ADDRESS…
Browse files Browse the repository at this point in the history
… is found in env
  • Loading branch information
oscarh committed Mar 1, 2008
1 parent bb8f32b commit 78667ec
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions src/wmii.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@

open Printf

(* Activate/deactivate debug *)
(* let debug_channel = ref None *)
let debug_channel = ref (Some stdout)

let debug str =
match !debug_channel with
| Some channel ->
output_string channel str;
flush channel
| None -> ()

(* Types/Globals *)
type color = {text:string; color:string; border:string}

Expand All @@ -45,20 +56,29 @@ let urgent_tags = ref []
let dmenu_on_bottom = ref true

(* Connection *)
let user = Sys.getenv "USER"
let adrs_exp = Str.regexp "unix!\\(.+\\)"
let screen_exp = Str.regexp ":[0-9]+"
let wmii_address =
let adrs = Sys.getenv "WMII_ADDRESS" in
if Str.string_match adrs_exp adrs 0 then Str.matched_group 1 adrs
else adrs
try
let adrs = Sys.getenv "WMII_ADDRESS" in
if Str.string_match adrs_exp adrs 0 then Str.matched_group 1 adrs
else adrs
with Not_found ->
let display = Sys.getenv "DISPLAY" in
let screen =
if Str.string_match screen_exp display 0 then
Str.matched_group 0 display
else
display in
let adrs =
Filename.concat ("/tmp/ns." ^ user ^ "." ^ screen) "wmii" in
debug (sprintf "Could not read WMII_ADDRESS, using: %s\n" adrs);
adrs

let user = Sys.getenv "USER"
let conn = O9pc.connect wmii_address
let rootfid = O9pc.attach conn user "/"

(* Activate/deactivate debug *)
(* let debug_channel = ref None *)
let debug_channel = ref (Some stdout)

let normcolors = ref {text = "#222222" ; color = "#eeeeee" ; border="#666666"}
let focuscolors = ref {text = "#ffffff" ; color = "#335577" ; border = "#447799"}
let urgentcolors = ref {text = "#222222" ; color = "#F5B800" ; border = "#447799"}
Expand All @@ -68,13 +88,6 @@ let font = ref "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
(* Action menu *)
let (actions : (string, (unit -> unit)) Hashtbl.t) = Hashtbl.create 10

let debug str =
match !debug_channel with
| Some channel ->
output_string channel str;
flush channel
| None -> ()

(* Core functions *)
let write conn rootfid file data =
let fid, iounit = O9pc.walk_open conn rootfid false file O9pc.oWRITE in
Expand Down Expand Up @@ -164,6 +177,7 @@ let client_tags () =
let current_tag () =
try
let data = read conn rootfid "/tag/sel/ctl" in
(* XXX There is more onfo here now, maybe we should use it? *)
String.sub data 0 (String.index data '\n');
with O9pc.Client_error _ -> ""

Expand Down

0 comments on commit 78667ec

Please sign in to comment.